Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lex.name] Reserved identifiers #532

Closed
FrankHB opened this issue Aug 21, 2015 · 8 comments
Closed

[lex.name] Reserved identifiers #532

FrankHB opened this issue Aug 21, 2015 · 8 comments

Comments

@FrankHB
Copy link
Contributor

FrankHB commented Aug 21, 2015

It seems that the term "identifier" in [lex.name]/3 does not cover macro names. Should it be moved to [lex.pptoken], or it is intended?

FrankHB referenced this issue in lhmouse/poseidon-archive Aug 21, 2015
@Arcoth
Copy link
Contributor

Arcoth commented Aug 21, 2015

But macro names are identifiers (see definition of control-line in §16/1), aren't they?

@FrankHB
Copy link
Contributor Author

FrankHB commented Aug 21, 2015

@Arcoth There are two kinds of identifier. One is of preprocessing-token, the other is of token. Macro names live in phases before tokens are recognized. BTW, keyword of token comes from identifier of preprocessing-token.

@zygoloid
Copy link
Member

It seems to me that [lex.name]/3 covers the general case of an identifier, not only the specific case of an identifier-as-a-token, so it also applies to macro names. Can you point to some specific wording that you find to be problematic here?

@FrankHB
Copy link
Contributor Author

FrankHB commented Aug 22, 2015

@zygoloid I don't think there are problems about the wording itself (as it in [lex.name] but not [lex.token]), but it might be clearer by adding some additional notes, or it can be placed elsewhere (i.e. [lex.pptoken]).
Two things are concerned:

  • [lex.name]/2 mentions "to interpret the token", but not "preprocessing token". So at least in this paragraph, "identifier" is of token, which is no longer a macro name (and cannot be a keyword) in that context. This is not consistent with [lex.name]/3.
  • [lex.key], which comes right after [lex.name], whose position also suggests the "identifier" in [lex.name] is of token rather than of preprocessing token.

@potswa
Copy link

potswa commented Oct 9, 2015

@FrankHB [lex.name]/2 is referring to language (not preprocessing) tokens, hence it says "When referred to in the grammar." (BTW, "referred to" is an awkward dangling preposition. Perhaps "When specified literally ([syntax] §1.6)" would be better.)

@zygoloid The problem might be "In addition" in ¶3, which suggests that keywords and contextual keywords are not to be used as macro names. You can still use #define override or #define delete as long as no standard library header is included, per §17.6.4.3.1 [macro.names]. Perhaps the recent DR meant to strengthen that rule as well?

[lex.name]/3 should not say "in addition," because it does not connect to ¶2. However, it should have a [Note] at the end referencing [macro.names] and mentioning that keywords are not otherwise reserved as pp-tokens.

Also, [lex.name]/2 should be moved into [lex.key], since the contextual keywords are a special case of keywords, not a special case of the identifier pp-token production.

@jensmaurer
Copy link
Member

I disagree with "Also, [lex.name]/2 should be moved into [lex.key], since the contextual keywords are a special case of keywords, not a special case of the identifier pp-token production." The contextual keywords are, in fact, identifiers and initially parsed as such. Only when the (parser) context is right do they become contextual keywords.

@jensmaurer
Copy link
Member

My suggestion: Remove "In addition" in [lex.name] p3, add "(including macro names)" in p3, and switch the order of p2 and p3.

It's a bit unfortunate that "identifier from preprocessing-token" is converted to "one of identifier, keyword, literal, operator, ...", using the same "identifier" string for both levels. Maybe we should have a pp-identifier in the long run.

@jensmaurer jensmaurer changed the title Reserved identifiers [lex.name] Reserved identifiers Dec 16, 2016
@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Dec 16, 2016
@zygoloid
Copy link
Member

zygoloid commented Mar 2, 2017

A pp-identifier would be a good solution, but it's not something we can reasonably do editorially. I'm closing this, but feel free to request a core issue if you still want changes here.

@zygoloid zygoloid closed this as completed Mar 2, 2017
@zygoloid zygoloid removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants