On Monday, 26 January 2015 at 22:09:44 UTC, Walter Bright wrote:
On 1/26/2015 1:25 PM, Jonathan Marler wrote:
The lexer would recognize these attributes as normal ID
tokens. The grammar
could be amended to allow a function to be decorated with
keywords and generic
id tokens. Then the meaning of those tokens would be handled
by semantic
analysis.
Not going to do that.
So the result would be that the lexer would see "nogc" and
"safe" as
normal id tokens (not keywords) which would be consumed as
function attributes
by the grammar. As far as I can tell this results in the best
of both worlds.
We can omit the '@' character on function attributes like safe
and nogc but they
don't have to be added as keywords.
I strongly dislike context sensitive tokens, whether or not
they are done by the lexer or the parser or the semantic
analysis.
It's like using a nail for a cotter pin.
Walter I hate to waste your time in answering my silly questions.
I know you have a much deeper knowledge and understanding of the
language then I. I can see that you believe my suggestion would
create some unnecessary complexity ("It's like using a nail for a
cotter pin"), however, I can't see how it would so I'm going to
ask another question. I can see that you are trying to save time
from your short responses so I'll understand if I understand if
you feel I'm a lost cause and do not respond again.
You said you strongly dislike "context-sensitive" tokens but I
still don't know exactly what you mean by "context-sensitive".
You said a token is "context-sensitive" if it is "A keyword in
one context and an identifier in another". However, since I'm
not proposing that "save" and "nogc" be keywords in any context,
this doesn't appear to fall under your definition. So I must
assume your real definition is more general. However, if the
definition is too general then couldn't you consider almost any
token "context-sensitive". For example, the token "static" or
"ref" have different meanings depending on their context, so are
they "context-sensitive"? Yes they are still keyword tokens, but
"safe" and "nogc" would still just be regular id tokens so what
makes "safe" and "nogc" more "context-sensitive" then "static"
and "ref"?
I'm honestly trying to understand. I can see from how the
grammar works that you don't agree my solution is a good one, but
I'm failing to understand why. I fail to see how allowing a
function to be decorated with id tokens is more complex then only
allowing keywords. Also sorry for harping on definitions, I
majored in Computer Science and Mathematics...having strict
definitions comes from my days of writing endless proofs.