Discussion:
Overload resolution of a qualified name
(too old to reply)
Il-seob Bae
2018-10-20 19:30:59 UTC
Permalink
Consider this function call:

foo::bar();

11.3.1.1.1, paragraph 3 [over.call.func] (N4778) covers this case:

In unqualified function calls, the name is not qualified by an -> or .
operator and has the more general form of a primary-expression. The name is
looked up in the context of the function call following the normal rules
for name lookup in function calls...
Here, foo::bar is an unqualified name, *in the sense that it's not
qualified by -> or .*. So this paragraph applies. Now, the meaning of the
phrase "looked up in the context of" is explained in 6.4, paragraph 2
[basic.lookup]:

A name “looked up in the context of an expression” is looked up as an
unqualified name in the scope where the expression is found.
However, foo::bar is a qualified name *in the realm of name lookup*. In
other words, *this combination of paragraphs basically say that*, the
qualified name foo::bar is looked up by the rule of unqualified name
lookup. However, I *don't* think that unqualified name lookup is capable of
recursively entering into a narrower scope, i.e., foo to bar. Is this a
defect?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
p***@lib.hu
2018-10-21 13:49:25 UTC
Permalink
[over.call.func] shows 3 forms and the 3 paragraph explains them. the last
states "not qualified by an -> or . operator" just to strictly point it is
describing the 3rd line of the alternative grammar. Beyond that selection,
forget it used the word "qualified" as it has no relation with its other
uses in other contexts.

I would not call it defect. As it did confuse you, it may qualify as
editorial issue and you may suggest a better wording through the report
editorial facility.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Il-seob Bae
2018-10-21 14:02:52 UTC
Permalink
I don't quite understand your answer. I agree with you, in that the word
"qualified" has a different meaning in this specific paragraph. Let me
explain my confusion by asking you several questions:

1. Do you agree that, `foo::bar` belongs to the 3rd forms, namely,
*primary-expression*? Then, by the same paragraph we just discussed, it's *looked
up in the context of the function call*.

2. Do you agree that, "looked up in the context of" refers to *unqualified
name lookup*? In other words, the qualified name `foo::bar` is looked up by
unqualified name lookup.

3. What in the world does it mean for a qualified name to be looked up by
unqualified name lookup?

Can you answer the last question?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Nicolas Lesser
2018-10-21 14:48:16 UTC
Permalink
So, here's what I think.

1. Yes.
2. No. Look at the whole sentence. It says "[...] following the normal
rules for name lookup in function calls.". This doesn't restrict name
lookup only to unqualified name lookup.
3. Nothing.

Only if there is no specification of the rules after the "looked up in the
context of *expr*" part, then [basic.lookup]p2 applies. So I don't think
this is a defect.
Post by Il-seob Bae
I don't quite understand your answer. I agree with you, in that the word
"qualified" has a different meaning in this specific paragraph. Let me
1. Do you agree that, `foo::bar` belongs to the 3rd forms, namely,
*primary-expression*? Then, by the same paragraph we just discussed, it's *looked
up in the context of the function call*.
2. Do you agree that, "looked up in the context of" refers to *unqualified
name lookup*? In other words, the qualified name `foo::bar` is looked up
by unqualified name lookup.
3. What in the world does it mean for a qualified name to be looked up by
unqualified name lookup?
Can you answer the last question?
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Il-seob Bae
2018-10-21 15:40:03 UTC
Permalink
Thank you for answering. Here are my thoughts:

1.

In that case, I suspect that the "looked up in the context of" part is
*redundant*, since "the normal rules" basically covers all the name lookup
rules. On stackoverflow, you suggested that

the names in a template-argument of a template-id are looked up in the
context in which the entire postfix-expression occurs.
has no specified behavior under the later part, namely, under "the normal
rules". Why is that? That basically refers to the whole 6.4, and the rule
is clearly written under it.

2.

As you pointed out, I actually didn't care much about the later part, since
the *"normal"* rules reminded me of the *"usual"* name lookup, which is
unqualified name lookup. Also, I interpreted *"following"* as *"abiding by"*,
but not as *"after"*. So, I thought that these two clauses are uniformly
referring to unqualified name lookup, and it leaded to a contradiction as
pointed above.
So, here's what I think.
1. Yes.
2. No. Look at the whole sentence. It says "[...] following the normal
rules for name lookup in function calls.". This doesn't restrict name
lookup only to unqualified name lookup.
3. Nothing.
Only if there is no specification of the rules after the "looked up in the
context of *expr*" part, then [basic.lookup]p2 applies. So I don't think
this is a defect.
Post by Il-seob Bae
I don't quite understand your answer. I agree with you, in that the word
"qualified" has a different meaning in this specific paragraph. Let me
1. Do you agree that, `foo::bar` belongs to the 3rd forms, namely,
*primary-expression*? Then, by the same paragraph we just discussed,
it's *looked up in the context of the function call*.
2. Do you agree that, "looked up in the context of" refers to *unqualified
name lookup*? In other words, the qualified name `foo::bar` is looked up
by unqualified name lookup.
3. What in the world does it mean for a qualified name to be looked up by
unqualified name lookup?
Can you answer the last question?
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Nicolas Lesser
2018-10-21 16:14:47 UTC
Permalink
Post by Il-seob Bae
1.
In that case, I suspect that the "looked up in the context of" part is
*redundant*, since "the normal rules" basically covers all the name
lookup rules.
Yeah, you could even strike that whole sentence I believe. But also, most
of that clause seems redundant. I'm not knowledgeable enough to figure out
if this is indeed the case or not though.

On stackoverflow, you suggested that
Post by Il-seob Bae
the names in a template-argument of a template-id are looked up in the
context in which the entire postfix-expression occurs.
has no specified behavior under the later part, namely, under "the normal
rules". Why is that?
Are you asking why there is this rule?

struct X { template<typename> static void f(); int a; };
void f() {
bool a;
X::f<decltype(a)>();
}

Without that exception, name lookup would have found X::a, and not f()::a.

That basically refers to the whole 6.4, and the rule is clearly written
Post by Il-seob Bae
under it.
2.
As you pointed out, I actually didn't care much about the later part,
since the *"normal"* rules reminded me of the *"usual"* name lookup,
which is unqualified name lookup.
The usual name lookup rules are the normal name lookup rules. Not sure what
you mean by that.

Also, I interpreted *"following"* as *"abiding by"*, but not as *"after"*.
Don't you mean the other way around? "After" is the wrong interpretation.

So, I thought that these two clauses are uniformly referring to unqualified
Post by Il-seob Bae
name lookup, and it leaded to a contradiction as pointed above.
So, here's what I think.
1. Yes.
2. No. Look at the whole sentence. It says "[...] following the normal
rules for name lookup in function calls.". This doesn't restrict name
lookup only to unqualified name lookup.
3. Nothing.
Only if there is no specification of the rules after the "looked up in
the context of *expr*" part, then [basic.lookup]p2 applies. So I don't
think this is a defect.
Post by Il-seob Bae
I don't quite understand your answer. I agree with you, in that the word
"qualified" has a different meaning in this specific paragraph. Let me
1. Do you agree that, `foo::bar` belongs to the 3rd forms, namely,
*primary-expression*? Then, by the same paragraph we just discussed,
it's *looked up in the context of the function call*.
2. Do you agree that, "looked up in the context of" refers to *unqualified
name lookup*? In other words, the qualified name `foo::bar` is looked
up by unqualified name lookup.
3. What in the world does it mean for a qualified name to be looked up
by unqualified name lookup?
Can you answer the last question?
--
---
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Il-seob Bae
2018-10-22 12:19:06 UTC
Permalink
I think that you're right. By comparing it to [over.call.func]p2, it became
much clearer. These two paragraphs *all *resolve ambiguity by explicitly
mentioning the relevant numbering, namely, *10.7* for the former and *6.4*
for the latter. That being said, the phrase "looked up in the context of"
in these paragraphs *doesn't seem* to carry a special meaning with it, *or*
the behavior would become eccentric.
Post by Nicolas Lesser
Post by Il-seob Bae
1.
In that case, I suspect that the "looked up in the context of" part is
*redundant*, since "the normal rules" basically covers all the name
lookup rules.
Yeah, you could even strike that whole sentence I believe. But also, most
of that clause seems redundant. I'm not knowledgeable enough to figure out
if this is indeed the case or not though.
On stackoverflow, you suggested that
Post by Il-seob Bae
the names in a template-argument of a template-id are looked up in the
context in which the entire postfix-expression occurs.
has no specified behavior under the later part, namely, under "the normal
rules". Why is that?
Are you asking why there is this rule?
struct X { template<typename> static void f(); int a; };
void f() {
bool a;
X::f<decltype(a)>();
}
Without that exception, name lookup would have found X::a, and not f()::a.
That basically refers to the whole 6.4, and the rule is clearly written
Post by Il-seob Bae
under it.
2.
As you pointed out, I actually didn't care much about the later part,
since the *"normal"* rules reminded me of the *"usual"* name lookup,
which is unqualified name lookup.
The usual name lookup rules are the normal name lookup rules. Not sure
what you mean by that.
Also, I interpreted *"following"* as *"abiding by"*, but not as *"after"*.
Don't you mean the other way around? "After" is the wrong interpretation.
So, I thought that these two clauses are uniformly referring to
Post by Il-seob Bae
unqualified name lookup, and it leaded to a contradiction as pointed above.
So, here's what I think.
1. Yes.
2. No. Look at the whole sentence. It says "[...] following the normal
rules for name lookup in function calls.". This doesn't restrict name
lookup only to unqualified name lookup.
3. Nothing.
Only if there is no specification of the rules after the "looked up in
the context of *expr*" part, then [basic.lookup]p2 applies. So I don't
think this is a defect.
Post by Il-seob Bae
I don't quite understand your answer. I agree with you, in that the
word "qualified" has a different meaning in this specific paragraph. Let me
1. Do you agree that, `foo::bar` belongs to the 3rd forms, namely,
*primary-expression*? Then, by the same paragraph we just discussed,
it's *looked up in the context of the function call*.
2. Do you agree that, "looked up in the context of" refers to *unqualified
name lookup*? In other words, the qualified name `foo::bar` is looked
up by unqualified name lookup.
3. What in the world does it mean for a qualified name to be looked up
by unqualified name lookup?
Can you answer the last question?
--
---
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Miguel TOLEDO GONZALEZ
2018-10-25 00:49:02 UTC
Permalink
My intuition says to me you're right...
Post by Il-seob Bae
I think that you're right. By comparing it to [over.call.func]p2, it
became much clearer. These two paragraphs *all *resolve ambiguity by
explicitly mentioning the relevant numbering, namely, *10.7* for the
former and *6.4* for the latter. That being said, the phrase "looked up
in the context of" in these paragraphs *doesn't seem* to carry a special
meaning with it, *or* the behavior would become eccentric.
Post by Nicolas Lesser
Post by Il-seob Bae
1.
In that case, I suspect that the "looked up in the context of" part is
*redundant*, since "the normal rules" basically covers all the name
lookup rules.
Yeah, you could even strike that whole sentence I believe. But also, most
of that clause seems redundant. I'm not knowledgeable enough to figure out
if this is indeed the case or not though.
On stackoverflow, you suggested that
Post by Il-seob Bae
the names in a template-argument of a template-id are looked up in the
context in which the entire postfix-expression occurs.
has no specified behavior under the later part, namely, under "the
normal rules". Why is that?
Are you asking why there is this rule?
struct X { template<typename> static void f(); int a; };
void f() {
bool a;
X::f<decltype(a)>();
}
Without that exception, name lookup would have found X::a, and not f()::a.
That basically refers to the whole 6.4, and the rule is clearly written
Post by Il-seob Bae
under it.
2.
As you pointed out, I actually didn't care much about the later part,
since the *"normal"* rules reminded me of the *"usual"* name lookup,
which is unqualified name lookup.
The usual name lookup rules are the normal name lookup rules. Not sure
what you mean by that.
Also, I interpreted *"following"* as *"abiding by"*, but not as *"after"*
Post by Il-seob Bae
.
Don't you mean the other way around? "After" is the wrong interpretation.
So, I thought that these two clauses are uniformly referring to
Post by Il-seob Bae
unqualified name lookup, and it leaded to a contradiction as pointed above.
So, here's what I think.
1. Yes.
2. No. Look at the whole sentence. It says "[...] following the normal
rules for name lookup in function calls.". This doesn't restrict name
lookup only to unqualified name lookup.
3. Nothing.
Only if there is no specification of the rules after the "looked up in
the context of *expr*" part, then [basic.lookup]p2 applies. So I don't
think this is a defect.
Post by Il-seob Bae
I don't quite understand your answer. I agree with you, in that the
word "qualified" has a different meaning in this specific paragraph. Let me
1. Do you agree that, `foo::bar` belongs to the 3rd forms, namely,
*primary-expression*? Then, by the same paragraph we just discussed,
it's *looked up in the context of the function call*.
2. Do you agree that, "looked up in the context of" refers to *unqualified
name lookup*? In other words, the qualified name `foo::bar` is looked
up by unqualified name lookup.
3. What in the world does it mean for a qualified name to be looked up
by unqualified name lookup?
Can you answer the last question?
--
---
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...