So, User-Defined Attributes

Jacob Carlborg doob at me.com
Sun Jan 6 06:29:21 PST 2013


On 2013-01-06 15:25, Philippe Sigaud wrote:

> That would mean two mixins, one internal and one external. Plus, that
> means every function where I want to propagate UDA has to be crafted
> exactly for this need.
>
> This is a drag. It seems natural to me that
>
> int foo(int i) { return i;}
>
> should forward i attributes. But maybe I need a shift my way to think
> about attributes. They are attached to declarations, not values...

Exactly.

> That's too bad, because declaring UDA is simple, and receiving them with
> arguments is easy also. There is a fundamental imbalance in having
> having propagating attributes through functions so difficult.

Yeah, if you want to work with UDA's you need to work with symbols, not 
values or types. If you want to pass a symbol, including its UDA, you 
need to pass it as an alias:

void foo (alias symbol) ()
{
     // access UDA of symbol
}

@(3) int a;
foo!(a);

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list