So, User-Defined Attributes

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jan 4 12:59:27 PST 2013


On 1/4/13 3:51 PM, Walter Bright wrote:
> On 1/4/2013 8:04 AM, Philippe Sigaud wrote:
>> So, I'm testing how to transfer UDA from one symbol to another.
>
> Remember, attributes are attached to the declaration. They are not
> transferred through initializers.
>
> This will do the transfer:
>
> import std.stdio;
> void main()
> {
> @(3, "hello") int i = 10;
> @(__traits(getAttributes, i)) double d2;
> writeln("[",__traits(getAttributes, d2), "]");
> }

For transfer templates are better than attributes.

Andrei


More information about the Digitalmars-d mailing list