DIP6: Attributes

Ary Borenszweig ary at esperanto.org.ar
Sat Aug 1 12:49:24 PDT 2009


Adam D. Ruppe escribió:
> On Sat, Aug 01, 2009 at 04:29:28PM -0300, Ary Borenszweig wrote:
>> http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP6
> 
> What's the difference between this and a keyword? It seems to be a keyword
> with a different name.

A keyword means changing the lexer, the parser and the semantic 
analysis. Annotations means only changing the semantic analysis (ok, 
changing the lexer and parser also, but just the first time to implement 
annotations). And if the first stage is implemented, what you describe 
below could also be implemented.

As the DIP says, the advantage is also reducing the huge amount of 
keywords that exist now in the language.

> For this annotation thing to be really useful, I'd think it should be well,
> dynamic for lack of a better word.
> 
> You can just list them on an item, then inspect them later in templates:
> 
> @magic int a;
> [...]
> 
> auto annotations = __traits(annotations, a);
> 
> assert(annotations[0] == "magic"); // now you can do whatever with this
> 
> 
> I wished I had something like this before, but I forgot why....
> 
> 
> 
> But if you aren't proposing something like that being possible, then what's
> the point of the @ to a keyword? It doesn't seem to be any different.

I could have included that in the DIP. But you have to start with small 
things, simple things, and evolve from that point. The DIP is just about 
how to start introducing annotations in the language with minimal 
changes to what exists now.



More information about the Digitalmars-d mailing list