Proposal: user defined attributes

Tove tove at fransson.se
Sun Mar 18 05:44:25 PDT 2012


On Sunday, 18 March 2012 at 12:39:19 UTC, F i L wrote:
> Tove wrote:
>> 1. x! would parse all decls at compile time...
>> 2. all attributes that need to modify the constructor is 
>> inserted at the points where the x! enabled constructors are 
>> declared/implemented...
>>
>> x!("@GC.NoScan @GC.Hot @attribute(Serializable.yes) int 
>> value;");
>>
>> x!(q{this()
>> {
>>  /* everything from 'x' is auto inserted here */
>>  my;
>>  normal;
>>  constructor;
>>  tokens;
>> });
>
> I see, that would work. But why not just build this same 
> operation into the compiler so the definition syntax is the 
> same as usual. The mixin's are powerful but a bit ugly. Not to 
> mention not IDE parser on the planet is going to be able to 
> figure out all that to give you intelligent code-completion.

Yes, I was thinking along these lines... what would be the 
absolutely bare minimum needed support this from the compiler to 
make this "scheme" look first class?

what if... the compiler encounters an unknown @token then it 
would delegate the parsing to a library implementation... which 
basically would do the above, but it would be hidden from the 
user... this way we would get a 0 effort(from the perspective of 
the compiler) and extensible syntax in library covering all 
future needs.



More information about the Digitalmars-d mailing list