Using attributes inside template instantiation

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 25 10:19:44 PDT 2014


On Wed, Jun 25, 2014 at 05:10:06PM +0000, Chris Nicholson-Sauls via Digitalmars-d-learn wrote:
> UDA's are compile-time metadata associated with a specific
> declaration.  So in something like:
> 
> @foo int x;
> 
> The @foo is attached to x, but is not part of the type.

The term "attribute" is a bit confusing, especially since "property" is
also used in the language to refer to something completely different. A
better term is perhaps "annotation". The @foo is an annotation on x, but
its type is just int. Furthermore, the @foo annotation on it only exists
at compile-type; it doesn't exist at runtime. The purpose is really to
enhance compile-time introspection and metaprogramming; but what the OP
wants seems to be something else altogether.

Sadly, the "attribute" terminology has stuck, and is unlikely to change.


T

-- 
What do you get if you drop a piano down a mineshaft? A flat minor.


More information about the Digitalmars-d-learn mailing list