User Defined Attributes

Sönke Ludwig sludwig at outerproduct.org
Tue Nov 6 01:24:42 PST 2012


Am 06.11.2012 09:39, schrieb Jakob Ovrum:
> On Tuesday, 6 November 2012 at 07:55:51 UTC, Walter Bright wrote:
>> -snip-
> 
> It doesn't look like it would be possible to schedule any runtime code
> using this, meaning they're not usable for stuff like registering types
> for serialization support, or doing runtime linking when attached to a
> function pointer, etc.
> 
> Even with user defined types or functions used in the attribute, the
> type or function itself doesn't know anything about the symbol it is
> being attached to, so it's quite limited what it can do.
> 
> Compared to other prevalent UDA systems, like C#'s, I'd say that this
> one is extremely limiting due to the two above points.
> 
> I'd love to hear some examples of what this particular take on UDAs
> allows in D, though.
> 

I see this as a feature in a way. The way C# attributes are sometimes
used can feel a lot like magic, because they can do things on their own.
In contrast it feels quite clean to me to simply think of attributes of
what the word means - a simple tag on the declaration.

Some otherwise possible globally operating applications may not be
doable without some boilerplate code. But a lot of stuff, including
controlling seralization, interface generation or statically checked
custom type constraints should be perfectly possible.


More information about the Digitalmars-d-announce mailing list