Jonathan M Davis wrote:
On Saturday 25 September 2010 22:59:51 Don wrote:
Jonathan M Davis wrote:
On Saturday 25 September 2010 03:23:12 Torarin wrote:
2010/9/24 Jonathan M Davis <jmdavisp...@gmx.com>:
However, we're not going to double the number of keywords that we have,
and the @ syntax has allowed us to remove some keywords and will allow
us to add more stuff later without having to add keywords.
Why are attributes not considered keywords? Because the compiler
doesn't care about them?
Because they don't need to be any more than variable names do. @
indicates that what follows is an attribute,  so the next symbol is
parsed as an attribute. If it were a keyword, then it wouldn't compile.
keywords are always treated as keywords no matter the context. They show
up explicitly in the grammar. Attributes do not show up explicitly in
the grammar any more than variables do. The grammar indicates when a
symbol is a variable, and it's parsed as variables. The grammar also
indicates when a symbol is an attribute, and it's parsed as an
attribute.

Basically, what it comes down to is that keywords are symbols in the
grammar - just like ! or ~ or <. Variable names and attributes are not.

Attributes allow us to add more modifiers to stuff (particularly
functions) without having to add new keywords. And someday, we may even
be able to define attributes in our own code (right now, they're all
known by the compiler) - and that's something that you obviously can't
do with keywords.

- Jonathan M Davis
You can already do that by prefixing with __.

Do you mean that you can use user-defined attributes as long as they're prefixed with _ or that you can use keywords if they're prefixed with _? Prefixing a keyword with _ makes it so that it's a different token, so it's not going to match any keywords. Now, if you mean that you could use your own attributes as long as they start with an underscore (.e.g. @_myproperty), then that could be useful, but I don't know how you'd be able to make use of it, since you'd need a way to get at through __traits or std.traits, and functionAttributes() (which is the only function that I see for looking at attributes) isn't string-based but rather flag-based, which means that it won't work with anything but a predefined set of attributes.

- Jonathan M Davis

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.

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."

Reply via email to