Proposal: user defined attributes

Manu turkeyman at gmail.com
Sun Mar 18 04:50:50 PDT 2012


On 18 March 2012 05:04, Kapps <opantm2+spam at gmail.com> wrote:

> On Sunday, 18 March 2012 at 01:48:07 UTC, Walter Bright wrote:
>
>> On 3/17/2012 6:39 PM, Manu wrote:
>>
>>> I'm sure C# already answers all these questions. It has precisely the
>>> same set
>>> of issues associated.
>>>
>>
>> C# doesn't have RAII, immutable, nor the notion of threadlocal/shared
>> types.
>>
>
> It has threadlocal using the [ThreadLocal] attribute which gets
> implemented by the compiler.
>
> 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 think that's a fair call. I wonder why Java feels the need for stateful
attributes.
I have made extensive use of java attributes that have been stateful.
Java's persistence api's rely on stateful attributes a lot, but I think
that can be done in other ways in D.

Compile-time attributes sound like a great start, it's much simpler. But
they do need to be able to 'do stuff', ie, add some property/method to a
field (using the field its self as the context pointer), not just simply
'tag' it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120318/93ebcaef/attachment-0001.html>


More information about the Digitalmars-d mailing list