On Sun, 02 Aug 2009 07:54:49 -0700, Robert Fraser <fraseroftheni...@gmail.com> wrote:
>Max Samukha wrote: >> On Sat, 01 Aug 2009 15:24:26 -0700, Robert Fraser >> <fraseroftheni...@gmail.com> wrote: >> >>> Ary Borenszweig wrote: >>>> http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP6 >>> I think annotations are a good idea, but turning keywords already in the >>> language into annotations seems kinda pointless & would kill backwards >>> compatibility. In C#/Java some things are modifiers while others are >>> annotations -- and with good reason. >>> >>> IMO, the focus of annotations should be mostly on things _external_ to >>> the compiler. So, serializability, thread safety, etc. Really, I think >>> annotations should be for compile-time reflection (so like someone else >>> said __traits(annotations, symbol) should return a tuple of annotation >>> structs. >> >> Please not a tuple of structs but a tuple of tuples. One should be >> able to specify types and aliases as annotation parameters. > >I wish that's work, but Tuples flatten themselves. Yes, but we can define a non-flattening tuple: template CannedTuple(A...) { alias A tuple; } Then we can have tuples of tuples: alias Tuple!(CannedTuple!(...), CannedTuple!(...), ...) annotations; // I guess, the first element should be the annotation name? enum annotationName = annotations[0].tuple[0]; We already can emulate custom attributes with mixins, though this requires template trickery that sometimes is overwhelming. So some syntax sugar would be welcome.