Date: Mon, 1 Jul 2024 15:16:45 +0200
On 30/06/2024 12.53, Jens Maurer wrote:
>
>
> On 30/06/2024 11.45, Federico Kircheis via Std-Discussion wrote:
>> On 30/06/2024 01.53, Andrew Schepler wrote:
>>> The entities found when searching for a name in a namespace scope are
>>> not always the same as the entities which are members of that namespace
>>> (and have names). The differences come up with using-declarations,
>>> using-directives, friend declarations, extern variables in block scope,
>>> and this situation: function declarations in block scope.
>>
>> Is this difference desirable or necessary?
>> Function declarations in block scope do not happen often, but since
>> "using-declarations, using-directives, friend declarations, extern
>> variables in block scope" are also affected, it seems desirable to me to
>> have the same rules in all situations.
>
> The rules have been like this since the dawn of C++. For example:
>
> namespace N {
> struct S {
> friend bool f();
> };
>
> bool b = ::N::f(); // error: does not find f
>
> bool f() { return false; }
> }
>
> If you feel a change is warranted in this area, this needs
> a paper with substantial rationale.
>
> In short, why should a declaration that is in a block scope
> ever affect name lookup outside of that block scope?
> Note that declaration matching is different from name lookup.
>
> Jens
Yes, I've noticed that it was since the dawn of C++.
Personally I think it would be simpler (as in less rules to acknowledge
when programming) if there would be no such difference.
Which is why I asked if it is (or was) desirable or necessary.
Since it is a such fundamental rule, that (I assume) might affect build
times or might change the behavior of a program (although I was not able
to come up with an example), I have currently no interest in trying to
write a paper for changing the current behavior :P
>
>
> On 30/06/2024 11.45, Federico Kircheis via Std-Discussion wrote:
>> On 30/06/2024 01.53, Andrew Schepler wrote:
>>> The entities found when searching for a name in a namespace scope are
>>> not always the same as the entities which are members of that namespace
>>> (and have names). The differences come up with using-declarations,
>>> using-directives, friend declarations, extern variables in block scope,
>>> and this situation: function declarations in block scope.
>>
>> Is this difference desirable or necessary?
>> Function declarations in block scope do not happen often, but since
>> "using-declarations, using-directives, friend declarations, extern
>> variables in block scope" are also affected, it seems desirable to me to
>> have the same rules in all situations.
>
> The rules have been like this since the dawn of C++. For example:
>
> namespace N {
> struct S {
> friend bool f();
> };
>
> bool b = ::N::f(); // error: does not find f
>
> bool f() { return false; }
> }
>
> If you feel a change is warranted in this area, this needs
> a paper with substantial rationale.
>
> In short, why should a declaration that is in a block scope
> ever affect name lookup outside of that block scope?
> Note that declaration matching is different from name lookup.
>
> Jens
Yes, I've noticed that it was since the dawn of C++.
Personally I think it would be simpler (as in less rules to acknowledge
when programming) if there would be no such difference.
Which is why I asked if it is (or was) desirable or necessary.
Since it is a such fundamental rule, that (I assume) might affect build
times or might change the behavior of a program (although I was not able
to come up with an example), I have currently no interest in trying to
write a paper for changing the current behavior :P
Received on 2024-07-01 13:16:51