[swift-evolution] Custom annotation processors?

Talin viridia at gmail.com
Wed Jan 13 19:24:29 CST 2016

As a former Googler, I've spent a lot of years writing Java code that uses
dependency injection, and this relies heavily on the ability to have custom
annotations/attributes in the language - particularly, user-defined
attributes on function parameters - and to generate additional code at
compile time via annotation processors. Although dependency injection does
have it's detractors, it's getting better (current best of breed is
http://google.github.io/dagger/), and it solves an amazing array of
problems, including the ability for asynchronous programming to disappear
into the underlying framework - you just write synchronous code and the
framework handles the rest (no more futures!).

Now, you can of course do dependency injection without custom attribute
support in the language, but it's much more cumbersome. The user-defined
attributes allow you to specify, in a simple declarative way, the runtime
dependencies between various classes. Without it you have to build up those
dependencies in code, using some sort of fluent interface or builder

So my question is, is there any plan for Swift to support user-created
annotations, and annotation processing compilation stages?

-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160113/0d9f7df5/attachment.html>

More information about the swift-evolution mailing list