DIP64: Attribute Cleanup

Mason McGill via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 21 22:49:33 PDT 2014


On Sunday, 22 June 2014 at 05:18:05 UTC, Jonathan M Davis via 
Digitalmars-d wrote:
> On Sun, 22 Jun 2014 00:12:20 +0000
> Mason McGill via Digitalmars-d <digitalmars-d at puremagic.com> 
> wrote:
>
>> "Attribute" and "property" are pretty much synonyms in English,
>> and it always seemed strange to me that D had to define them as
>> different--yet confusingly similar--entities.
>
> They're not even vaguely similar in D. A property is a member 
> of a struct or
> class which is a variable or a function which emulates a 
> variable, whereas
> attributes are annotations put on symbols (currently just 
> classes, structs,
> and functions AFAIK) which indicate extra information to the 
> compiler and to
> type introspection.
>
> So, while I can see why you might dislike the fact that 
> attribute and property
> do not mean the same thing in D, they're _not_ at all similar 
> it how they're
> used, so I find it very odd if anyone is confusing them. And 
> it's not like D
> pioneered these meanings for attributes and properties. C# uses 
> them for the
> same things.
>
> - Jonatahn M Davis

I was referring to the `Property` and `PropertyIdentifier` 
entities in the D grammar (http://dlang.org/attribute.html), 
which are special cases of attributes. "New-style" attributes, 
like "property", "safe", and "nogc", are `PropertyIdentifier`s 
and need to be written with the "@" character. Older, 
non-property attributes, like "pure" and "nothrow", do not.

Sorry if this wasn't clear in the former post.


More information about the Digitalmars-d mailing list