[swift-evolution] Custom annotation processors?

Fons Rademakers Fons.Rademakers at cern.ch
Thu Jan 21 11:45:37 CST 2016


Hi Chris,

  many thanks for the pointer. Will there also be a method or function calling interface, so interfaces can be discovered and called at run-time. Something we abundantly use via the Cling interpreter.

Cheers, Fons.


> On 19 Jan 2016, at 15:20, Chris Lattner <clattner at apple.com> wrote:
> 
> 
>> On Jan 19, 2016, at 7:10 AM, Fons Rademakers <Fons.Rademakers at cern.ch> wrote:
>> 
>> Hi Chris,
>> 
>> is there a document or notes on discussions on reflection metadata representations and an API to access them? We are very interested in this as it essential to have that make a powerful I/O system, like we have in ROOT, it is mandatory to be able to find out at run-time all possible object details. User defined attributes are in our case used to annotate e.g. transient data members that should not be streamed, or the precision with which a certain data member should be streamed (a double that could be streamed with a much lower precision saves a lot of bytes in the output, etc.).
> 
> Hi Fons,
> 
> There is some early documentation here:
> https://github.com/apple/swift/blob/master/docs/ABI.rst#type-metadata
> 
> Slava is the one working on this area IIRC.
> 
> -Chris
> 
> 
>>> On 13 Jan 2016, at 22:58, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> 
>>>> On Jan 13, 2016, at 5:24 PM, Talin via swift-evolution <swift-evolution at swift.org> wrote:
>>>> 
>>>> 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 pattern.
>>>> 
>>>> So my question is, is there any plan for Swift to support user-created annotations, and annotation processing compilation stages?
>>> 
>>> Hi Talin, 
>>> 
>>> We have no concrete plans for user defined attributes, but it is a natural extension.  One of our goals for Swift 3 is to nail down the reflection metadata representation.  We should design this to be extensible to support user defined attributes so that we don’t close this off in the future.
>>> 
>>> -Chris
>>> 
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> --------------------------------------------------------------------------
>> Dr. Fons Rademakers      CERN - European Organization for Nuclear Research
>> Chief Research Officer   1211 Geneve 23, Switzerland
>> CERN openlab             Tel: +41227679248            Mobile: +41754113742
>> --------------------------------------------------------------------------
>> 
> 

--------------------------------------------------------------------------
Dr. Fons Rademakers      CERN - European Organization for Nuclear Research
Chief Research Officer   1211 Geneve 23, Switzerland
CERN openlab             Tel: +41227679248            Mobile: +41754113742
--------------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3029 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160121/453ef3f7/attachment.p7s>


More information about the swift-evolution mailing list