Proposal: user defined attributes

Jacob Carlborg doob at me.com
Mon Mar 19 03:15:22 PDT 2012


On 2012-03-19 09:01, Tove wrote:
> Well I was thinking if we can go one step further than C#, because of
> D:s CTFE... by introducing a call back from the D compiler to the
> library CTFE attribute handler... this way we can hide all reflection
> from the "end user"... and the compiler doesn't need to know anything at
> all, as the library does the semantic lowering.
>
> @GC.NoScan int value;
> @GC this() {}
>
> Compiler Asks library for transformation of unknown @GC
> bool library("@GC this() {anything...}") ->
>
> if the library succeeds it would then transform the string and hand back
> a lowered mixin to the compiler.
>
> mixin("
> this()
> {
> auto b = [ __traits(allMembers, D) ];
> foreach( auto a; b) {DO.GC.Stuff...}
>
> anything...
> }
> ");

That would be cool.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list