The Wrong Stuff

Michel Fortin michel.fortin at michelf.com
Sun Sep 26 06:26:28 PDT 2010


On 2010-09-26 03:56:32 -0400, Don <nospam at nospam.com> said:

> I was just referring to the "without having to add new keywords" bit. 
> And a fairly general comment to the whole thread (not just this post). 
> I meant that __keywords are available, and the argument that @ provides 
> a namespace for keywords is completely wrong, and utterly dreadful. I'm 
> a bit disturbed that people are even thinking in that way.

People (including me) are thinking that way because there is no sane 
semantic definition of what the @ syntax stands for. I'll grant you one 
thing: @attributes are only used to affect declarations in one way or 
another, so as long as this stands they're more limited in purpose than 
keywords in general. But beyond that, what makes @ different from 
another namespace for keywords?


> See also the August 28 post by Herb Sutter:
> http://herbsutter.com/
> 
> "My biggest (but not only) beef with C++0x [[attributes]] is that the 
> standard itself was abusing attributes as disguised [[keywords]]. 
> Attributes are acceptable as pure annotations, but they should have no 
> semantic effect on the program.
> [snip]
> it’s a clear example of adding language keywords dressed in attributes’ 
> clothing, and not something I want to be responsible for forcing three 
> million C++ developers to live with until the end of time."

Unfortunately, one attribute with the @ syntax in D -- and I'd say the 
flagship one as it was the first and most discussed -- is not a pure 
annotation as it has a noticeable effect on semantics. I'm talking 
about @property which, if it ever get implemented, changes your 
function so it simulates a field. In Herb's terms, @property is clearly 
a keyword in disguise.

And then you realize many keywords fit that same definition of an 
attribute (deprecated, pure, nothrow...) and you're left with a very 
fuzzy concept of what the @ syntax is for. We have an important keyword 
disguised as an @attribute (@property) and attributes disguised as 
keywords for historical reason (deprecated, pure, nothrow...). Whatever 
the @ syntax was supposed to stand for, it's pretty messed up right now.

There's also confusion about the term "attribute" itself. Try reading 
that page and come with a sane definition of what is an attribute in D.
<http://digitalmars.com/d/2.0/attribute.html>


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list