Proposal: user defined attributes

Walter Bright newshound2 at digitalmars.com
Sun Mar 18 01:03:29 PDT 2012


On 3/17/2012 10:01 PM, F i L wrote:
> Walter Bright wrote:
>> My impression is it is just obfuscation around a simple lazy initialization
>> pattern.
>>
>> While I can see the abstraction usefulness of compile time attribute metadata,
>> I am having a hard time seeing what the gain is with runtime attributes over
>> more traditional techniques.
>
> I'm not sure exactly what you mean by runtime attributes. Do you mean the
> ability to reflect upon attributes at runtime?

I mean there is modifiable-at-runtime, instance-specific data.

> In that case, there's two
> benefits I can think of over "traditional" member data: Instance memory
> (attributes are create at reflection),

Lazy initialization is a standard pattern. No special language features are 
needed for it.

> and reusable metadata packages (similar
> to how you might use mixin templates only with less noise and reflection
> capabilities).

Sounds like a garden variety user-defined data type.

Again, I am just not seeing the leap in power with this. It's a mystery to me 
how a user defined "attribute class" is different in any way from a user defined 
class, and what advantage special syntax gives a standard pattern for lazy 
initialization, and why extra attribute fields can't be just, well, fields.


More information about the Digitalmars-d mailing list