C++ Logo

std-proposals

Advanced search

Re: [std-proposals] String Slicing Draft Proposal

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Tue, 19 Mar 2024 20:26:00 +0000
On Tue, 19 Mar 2024 at 17:57, Breno GuimarĂ£es via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> For what it's worth, I strongly disagree with "s[i, j] seems actively bad". I think the level of confusion with this syntax will be minimal. I would be very surprised if developers try to "multi-index" into a string (which doesn't even make sense) and are surprised that it doesn't work.
>
> Several operations in C++ have the same syntax and slightly different meanings. And several operations have drastically different meaning (like operator * and multiplication).
> Another example is operator/ for std::filesystem::path. I don't recall seeing angry developers complaining that / is not dividing their path but appending.
> It's all about the context.

But operator/ only means *one* thing for a filesystem::path.

Barry's point is that for a multi-dimensional array we might want
multi-indexing into it, and we might also want to support taking a
slice of it. If x[i,j] means multi-indexing for some types, and
slicing for other types, what does it mean for types that support both
multi-indexing and slicing?

Received on 2024-03-19 20:27:19