Date: Sat, 29 Apr 2023 12:26:06 +0200
On Saturday, 29 April 2023 03:46:10 CEST Bjarne Stroustrup via Ext wrote:
> On 4/28/2023 8:55 PM, Ville Voutilainen wrote:
> > On Sat, 29 Apr 2023 at 03:40, Bjarne Stroustrup <bjarne_at_stroustrup.com>
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".
Yes, I believe we need to cater to users that want bounds checking *and*
those that don't.
As for another variation of the workaround:
import std;
namespace PPP
{
using namespace std;
struct vector {
void found_our_own() {}
};
int main(int argc, char** argv);
}
int main(int argc, char** argv) { return PPP::main(argc, argv); }
// students will then have to work in the PPP namespace:
namespace PPP
{
int main(int argc, char** argv) {
vector v;
v.found_our_own();
}
}
Name lookup finds PPP::vector and looks no further.
-Matthias
> On 4/28/2023 8:55 PM, Ville Voutilainen wrote:
> > On Sat, 29 Apr 2023 at 03:40, Bjarne Stroustrup <bjarne_at_stroustrup.com>
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".
Yes, I believe we need to cater to users that want bounds checking *and*
those that don't.
As for another variation of the workaround:
import std;
namespace PPP
{
using namespace std;
struct vector {
void found_our_own() {}
};
int main(int argc, char** argv);
}
int main(int argc, char** argv) { return PPP::main(argc, argv); }
// students will then have to work in the PPP namespace:
namespace PPP
{
int main(int argc, char** argv) {
vector v;
v.found_our_own();
}
}
Name lookup finds PPP::vector and looks no further.
-Matthias
-- ────────────────────────────────────────────────────────────────────────── Dr. Matthias Kretz https://mattkretz.github.io GSI Helmholtz Centre for Heavy Ion Research https://gsi.de stdₓ::simd ──────────────────────────────────────────────────────────────────────────
Received on 2023-04-29 10:26:11