The Wrong Stuff
Jonathan M Davis
jmdavisProg at gmx.com
Sat Sep 25 04:09:22 PDT 2010
On Saturday 25 September 2010 03:23:12 Torarin wrote:
> 2010/9/24 Jonathan M Davis <jmdavisProg at 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
More information about the Digitalmars-d
mailing list