Thread overview
Attributes
Dec 23, 2006
Craig Black
Dec 23, 2006
Daniel Keep
December 23, 2006
C# has a feature called "attributes" that allows metadata to be extended with custom information.  This would be very useful in D.  Basic support for attributes in D would be possible by adding an array of objects to the TypeInfo class.  Developers would need the ability to add attributes, and retrieve attributes from this array.

This feature seems easy to implement and has a great deal of utility. Without boring anyone with details, it would make my code much more elegant in many ways.  It would also open up some interesting new possiblities including fast dispatch for multimethods.

-Craig


December 23, 2006
Craig Black wrote:
> C# has a feature called "attributes" that allows metadata to be extended
> with custom information.  This would be very useful in D.  Basic support for
> attributes in D would be possible by adding an array of objects to the
> TypeInfo class.  Developers would need the ability to add attributes, and
> retrieve attributes from this array.
> 
> This feature seems easy to implement and has a great deal of utility.
> Without boring anyone with details, it would make my code much more elegant
> in many ways.  It would also open up some interesting new possiblities
> including fast dispatch for multimethods.
> 
> -Craig
> 

Actually I'm inclined to agree that it has its uses.  Among the changes my Bovis projects makes from its predecessor is adding of attributes to objects.  (As symbols whose value is presence/absence.  A Bovis Object either is or is not '__Core, or '__Class, or '__Int, etc.)

One would almost need a new operator/surrogate for this purpose.  And one has to decide if attributes are a compile-time or run-time feature, whether they apply to the type, the variable, or both... etc.  Maybe here at last is a use for the poor @ character?  ;)

Just thinking "aloud".

-- Chris Nicholson-Sauls
December 23, 2006
Chris Nicholson-Sauls wrote:
> Craig Black wrote:
> 
>> C# has a feature called "attributes" that allows metadata to be extended
>> with custom information.  This would be very useful in D.  Basic support for
>> attributes in D would be possible by adding an array of objects to the
>> TypeInfo class.  Developers would need the ability to add attributes, and
>> retrieve attributes from this array.
>>
>> This feature seems easy to implement and has a great deal of utility.
>> Without boring anyone with details, it would make my code much more elegant
>> in many ways.  It would also open up some interesting new possiblities
>> including fast dispatch for multimethods.
>>
>> -Craig
>>
> 
> Actually I'm inclined to agree that it has its uses.  Among the changes my Bovis projects makes from its predecessor is adding of attributes to objects.  (As symbols whose value is presence/absence.  A Bovis Object either is or is not '__Core, or '__Class, or '__Int, etc.)
> 
> One would almost need a new operator/surrogate for this purpose.  And one has to decide if attributes are a compile-time or run-time feature, whether they apply to the type, the variable, or both... etc.  Maybe here at last is a use for the poor @ character?  ;)
> 
> Just thinking "aloud".
> 
> -- Chris Nicholson-Sauls

'@' already has a use... CWEB (and by extension, DWEB) uses it.  :P

	-- Daniel