Proposal: user defined attributes

Walter Bright newshound2 at digitalmars.com
Sat Mar 17 20:08:57 PDT 2012


On 3/17/2012 8:04 PM, Kapps wrote:
> It has threadlocal using the [ThreadLocal] attribute which gets implemented by
> the compiler.

That's a storage class, not a type constructor. In D, threadlocal/shared is a 
difference in the type.

> In C#, all attributes live inside the TypeInfo/MethodInfo/etc for the
> class/struct/method/field/parameter. I don't see this being a problem. I can't
> think of good use cases where an attribute/annotation should be per-instance at
> all, particularly with the compile-time power that D has, whereas C# does not
> have any. Honestly, most uses of attributes in D would be done at compile-time,
> and I think that's acceptable until/if runtime reflection is put in. If it is
> needed, it can live inside TypeInfo/MethodInfo, but is (imo) absolutely not
> needed on a per-instance basis. This is the job of fields or interfaces.

I also do not get why per-instance attributes even exist, as I agree that's what 
fields are for.


More information about the Digitalmars-d mailing list