I think I'm cool with this too.  John: Can you write a proposal addressed to EWGI?  Do you know how?  Have you done it before?  Let us know if you need help.  -Andrew

On Wed, Apr 26, 2023 at 12:34 PM Barry Revzin via Std-Proposals <std-proposals@lists.isocpp.org> wrote:


On Mon, Apr 24, 2023, 9:52 AM John Filleau via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Floating the idea for Grouped-namespace "using" statements.

A grouped-namespace using statement is a shorter way to write multiple using statements that share a parent namespace.

using a::b::c::X, a::b::c::Y, a::b::c::Z;

can be replaced with

using a::b::c::{X, Y, Z};

PROBLEM

Sometimes I have long namespace names, and I want to alias things from that namespace. The current way to do that requires me to retype the namespace a lot. See above.

This is annoying at time-of-writing because of the repetition and opportunity for typos. This is annoying at time-of-maintenance when namespace names change.

SOLUTION

Allow grouped-namespace using statements as seen above.

BENEFIT

100% ergonomics.

This solves no interesting computer science problems, nor does it introduce world peace.

DOWNSIDES

I have 0 understanding of the edge cases around this. I just know I want it. If other people want it, we should make it part of the standard.

COST

One more thing that implementations have to handle.

I like this idea. Saves on repeating the namespace, which has very little benefit at that point. Plus it's common for people to just avoid using namespace in preference to using declarations, which are quite verbose today due to the namespace repetition. 

Even if the namespace is short, like:

using std::cout, std::endl;

This kind of stuff adds up fast, and

using std::{cout, endl};

is just clearer.

You can't have a { after :: today, so there's no ambiguity. This does make parsing a using declaration more complicated, since it's no longer just a sequence of qualiifed-ids, but it's probably not exceedingly difficult. 

Barry
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals