Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
C# 6.0 feature: nameof expressions #10
C# 6.0 feature: nameof expressions #10
Changes from all commits
2ed4b4f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not read correctly to me. By "Grammatically" is "Semantically" or "Syntactically" meant? From a syntactic view a name_entity is always a name_entity. Now the language the grammar represents may be a subset of the language of expressions but that does not make it an expression either syntactically or semantically. I think what we are trying to say is that a name lookup succeeds then the named_entity is treated semantically as an invocation_expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuing thought... This para is a backward compatibility statement, should there be some typographical indication that this is what it is? And (having not looked myself so there might be...) should there be a corresponding compatibility note where function declarations are describe a note stating that
nameof
should be avoided by is (currently?) allowed for backward compatibility?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be worth highlighting somewhere that if the name in the source code
nameof
expression is an alias for the entity, it's that source expression that's relevant, not the resolved entity. For example:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Its value is the last identifier of the named_entity" probably covers it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Add a note to explain this after that paragraph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not why a named_entity is not an expression but a named_entity? I.e. something like (typed on the fly, not wordsmithed!) "its named_entity is not an expression (despite its syntactic similarity?) and therefore is not part of definite assignment analysis"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to work out whether this should compile:
(It doesn't currently.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is deemed a lookup error, it's already covered - Jon to check that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've currently only found a reference in https://github.com/ECMA-TC49-TG2/csharpstandard/blob/draft-v6/standard/variables.md, which is within a note:
I'm assuming there must be something normative somewhere... but I can't see anything in 12.7.3. (It's a shame if someone has to read the whole spec to know that the result of a lookup in 12.7.3 is invalid.) Let's discuss whether this needs a new issue...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that a single example referring to a lot of different kinds of entity would be best here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A number of entities that should be used here:
System.Int
)List<int>
).System
namespaceSystem.Collections.Generic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.