custom attribute proposal (yeah, another one)

Andrej Mitrovic andrej.mitrovich at gmail.com
Fri Apr 6 08:53:00 PDT 2012


On 4/6/12, Piotr Szturmaj <bncrbme at jadamspam.pl> wrote:
>> @attribute Author author(string name) { return Author(name);}
>
> Compare it to:
>
> struct Author { string name; }
>
> @Author("John Doe") int x;

I assume we could use templated functions:

struct Author { string name; }
@attribute T temp(T, Args...)(Args args){ return T(args);}
@temp!Author("John Doe") int x;

On 4/6/12, Piotr Szturmaj <bncrbme at jadamspam.pl> wrote:
> Compiler can easily deal with structs too:
>
> enum author = Author("John");
> pragma(msg, author.name);

Just throwing this out there that's semi-related: there's a bug w.r.t.
struct constructors and enums:
http://d.puremagic.com/issues/show_bug.cgi?id=5460


More information about the Digitalmars-d mailing list