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
[expr.type]/1 Change "designates" to "result of" #2876
base: main
Are you sure you want to change the base?
Conversation
Hm... I'm not convinced. Maybe it helps already to switch around the sentence and first say that we turn the expression into an lvalue or xvalue, and then either keep the "designates" or use "denotes" [basic.lval] p5. |
@jensmaurer Here, let me provide an example:
Here, On top of this, not changing what the expression results in would make no sense. A glvalue is said to evaluate to (result in) an object, bit-field, or function. If this wording did not apply to the result of the expression, the result would be a reference, which is clearly not intended. |
We're riding the edge between expression per the grammar and interpreting that expression as a semantic construct. I think it's clear in [dcl.type.decltype] p1 that we're not applying [dcl.type] p1 to the expression if one of the special cases applies; instead, we're stopping right after name lookup found an entity for the id-expression. Back to [dcl.type] p1. This is a step in interpreting expression (grammar) as the semantic construct "expression". We're not super-clear on the order here, but what happens is that we (recursively) interpret the expression by the other rules in [expr], and then, at the end, if we get a "reference to T", we perform the adjustment discussed here, and keep interpreting any enclosing expressions. My specific suggestion here would be: [needs more massaging to reflect that rvalue references to functions yield lvalues, but if we say this, we can replace half of [conv] p6 with a note and a cross-reference]:
I use "denote" here so that we tie into the "result of" definition in [basic.lval] p5. |
@jensmaurer It would be more appropriate to use the proper grammar term "result", to describe the semantic construct "expression", since the result of the expression and the entity it denotes can differ. Additionally, [dcl.type] is not clear when it alludes to an entity denoted |
I see that we're using "the result is" elsewhere, but we're also using "designates", e.g. in [expr.ref] p6.1. Personally, I'd consider a change that talks about the result being a glvalue first and then saying what it refers to more helpful for comprehension than the change from "designates" to "the result is". We'll keep this in the queue so that @zygoloid can decide, eventually. |
@jensmaurer After some further examination, I've decided that this is not the best way to go. Changing it to "result of" could result in some incongruency between what an expression denotes and what it's result it. In the above example |
Here are some of my thoughts after reading discussion here and a piece of the standard. First of all, names denote. [basic.lookup]/1 says:
But they don't denote in the sense how glvalues denote objects or functions. expr.prim.id speaks about So, this is the first "face" of This is kinda unfortunate, because
(i.e.
Maybe, Now, to Let me add a couple more words about [expr.type]/1. Just look what it says «The expression designates the object or function denoted by the reference». As if it were possible to denote a reference! Well, technically, "reference" is among things which are called "entities". There is an opinion that "value" and "object" should not be "entities". I believe "reference" also should not be "entity". One can denote a variable of reference type, or just reference type. I don't know what does it mean to denote a reference. I believe it is impossible to "create" a reference the same way it is possible to create an object. Any wording that speaks about reference creation is IMO defective. |
I think it would be great to syntactically separate cases when The changes in the grammar would be:
Proposed:
Rationale: Currently:
Proposed:
Rationale: Currently:
Proposed:
Rationale: The definition of Thoughts? |
I would argue that the id-expression on the right side of a class member access is an expression. Anyways, the syntax tree is only significant in establishing syntax, so it would really be much different other than having two names. |
[expr.ref] doesn't read to me so. |
It would be a prvalue, as specified by [expr.prim.id] |
Hmmm....
Well, look at the
It has
I think I don't really get what do you want to say here. |
Ah, whoops. I didn't check [expr.prim.id.qual], my bad. Either way, its an expression. |
I am sympathetic to the id / id-expression idea, where "id" is used when we have a name that is not in an expression context, similar to conditional-expression / constant-expression. Do we have a grammar-term that is slightly longer than "id"? However, introducing id / id-expression seems a bit large of a change for an editorial issue, for instance because it involves introducing new grammar non-terminals. Can we maybe proceed with the rather narrow change that we discussed earlier? |
What do you think about
I'm not proposing this as an editorial fix. I'm more like thinking out loud how a paper fixing the mess could look like. And the fix of grammar is only a tiny part of this imaginary paper. |
name would work, but it would introduce a disparity between the defined term and the grammatical production (since a name is not qualified). |
I agree that declarator-id as well as the E2 in class member access are candidates for id instead of id-expression. We don't have to talk about what E2 means alone as long as we know what E1.E2 means. (Actually, you can't even do name lookup for E2 without looking at E1 first.) |
When the change to the result of the expression is done as specified in [expr.type] p1, the wording does not accurately reflect what happens. The entity the expression refers to does not change, but the result of the expression is changed to be the object or function that the reference refers to does. The wording should reflect that, hence this proposed change.