C++ Logo

sg20

Advanced search

Re: namespace composition

From: Bjarne Stroustrup <bjarne_at_[hidden]>
Date: Fri, 28 Apr 2023 21:46:10 -0400
On 4/28/2023 8:55 PM, Ville Voutilainen wrote:
> On Sat, 29 Apr 2023 at 03:40, Bjarne Stroustrup <bjarne_at_[hidden]> wrote:
>>> Name lookup in C++ is complicated. :P
>> Too complicated, and there is probably little we can do about it.
> Right, but we would curse the language if it just allowed what you're
> trying to do, when programming at scale(*). You have
> an altruistic hack here, but it's still a hack.

Agreed. What we need is a way of getting a portable guarantee that range
checking is done for at least non-sneaky uses. This fits with "profiles".


> You're trying to take
> everything that's in std, but sneak
> in an alternative for vector, with slightly different semantics. The
> language quite reasonably says "Whoa. If you
> want that, establish a new namespace where you can decide what the
> rules are, but no such sneaking under
> my watch." And it does the same if you attempt to sneak in via another
> route, by doing a using-directive of PPP
> and then using unqualified names. The language says "I told you this
> is not okay, don't try to dance around that."
>
> (*) I mean, imagine working on a large project, getting puzzled why
> your vectors don't seem to work as expected,
> and then finding out a sneak-in. You would curse. You would think that
> the language shouldn't allow such
> sneaking to occur.

Received on 2023-04-29 01:46:12