Proposal: user defined attributes

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


On Sunday, 18 March 2012 at 12:10:23 UTC, F i L wrote:
> Tove wrote:
>> Hmm... well if the x declarations store all NoScan objects in 
>> a collection, it could be injected into the constructor token 
>> stream later...
>>
>> x!("@GC.NoScan int value;");
>>
>> // modified by x to insert a foreach with GC.setAttr
>> x!(q{this() {/* foreach(...) GC.setAttr(...); */ });
>
> But if x!() pumps out a constructor, how do you add multiple 
> attributes with @GC.NoScan? The constructors would collide.

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;
});



More information about the Digitalmars-d mailing list