-
Notifications
You must be signed in to change notification settings - Fork 7
[basic.lval] p5 An id-expression naming the reference denotes the reference #44
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
Comments
This is all part of the entity (variable) vs. object confusion |
A plethora of verbs appear to be in use to talk about the object to which a glvalue or a reference refers. [conv.lval] p3 uses "refers" and "indicated". [basic.lval] p5 and p11 uses "denotes" We should use a consistent verb form here. |
It seems "denotes" should be used for "the result of name lookup", e.g. a name denotes a variable or a function. See basic.pre p5. We should pick another verb for references and glvalues. |
Yes, this is the concern of this issue. Furthermore, we don't give a consistent meaning to "reference binding" as well. Consider [dcl.init.ref] p5.1 and p5.3
So, whether the reference binds to the expression or an entity(i.e. an object or a function)? In [over.ics.rank] subclause, we basically say the reference binds to either an lvalue or rvalue(i.e. the expression). |
Agree! "denote" is correctly used in [expr.prim.id.unqual] and [expr.prim.id.qual]. First, [basic.pre] p5 says
The name could be an unqualified name or a qualified name. [expr.prim.id.unqual] p3 says
[qualified-id] p5 says
[qualified-id] p5 might be clearer after adopting cplusplus/draft#5346 I think once we determine that the "verb" |
The problem is that we use qualified-id and unqualified-id both for the expression / glvalue sense (which object are we talking about?) and in the identifier sense (which variable or data member are we talking about?) Those two meanings need to get a clear divorce, and the right approach is to move the variable / data member interpretation into [basic], and only leave the glvalue / expression interpretation in [expr]. |
IIUC, do you mean that the name of a variable or data member can be associated with several objects? I want to divorce objects from variables. "variable" should have a pure meaning that its name could be used to refer to (conceptually) objects or references as determined by the declaration. For the problem that which object is designated/referred to by the name, I think it is determined by the evaluation of the In the current, the entity is an object, function, or something else specified in [basic.pre].
I construe this rule as that the name is used to denote (conceptually)objects rather than the concrete object. Because [basic.lookup] only associates the name with the found declaration, it cannot determine which object the name refers to. This part has been discussed in cplusplus/draft#5346 (comment) |
Yes. Think about a local variable in a recursive function: you get a different object for each invocation. |
The problem coincidently falls into the discussion about variables in cplusplus/draft#5346. We want "variable" to be an entity(object is not an entity), then the name denotes the "variable", as @opensdh said in cplusplus/draft#5346 (comment). The "reference" should also have the same problem(per thread or in a recursive function). We might consider "use a consistent verb" as the primary concern in this issue. |
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[basic.lval] p5 says
Consider this example:
In this case,
rf
is an unqualified-id denoting the reference, per [expr.prim.id.unqual] p3 and [basic.pre] p5. whilstrf
is also an lvalue as per [expr.prim.id.unqual] p3. According to [basic.lval] p5, the result of lvaluerf
is the reference. However, aglvalue
either denotes an object or a function, the result of the lvaluerf
should intend to be the object denoted bya
. Maybe, we should use "designate" in place of "denote" in [basic.lval] p5, as the following:Everywhere, we should clearly define what entity the expression designates. Such as, we have defined what entity an unqualified-id introduced by a reference declaration designates in [expr.type] p1
Such as changing [expr.unary.op] p1 as the following:
The text was updated successfully, but these errors were encountered: