C++ Logo

sg16

Advanced search

Re: [SG16-Unicode] Namespaces

From: JeanHeyd Meneide <phdofthehouse_at_[hidden]>
Date: Fri, 12 Apr 2019 10:02:07 -0400
On Fri, Apr 12, 2019 at 6:45 AM Lyberta <lyberta_at_[hidden]> wrote:

> I guess at least teachability and clean structure. The guidance would
> be: "stuff in std is old and unusable for text, stuff in std::text is
> new and usable".
>

Having `std::text::text` is a bit of a weird class type (unless we give it
a new name), and it's impossible to have `std::text` as a type and
`std::text` as a namespace at the same time.

The sub-namespace isn't really necessary here because we are not in
competition for certain names or algorithms, save for the 3 names I want to
specifically name `std::text_decode`, `std::text_encode`,
`std::text_transcode`, and similar because it internally implies other
semantics and I do not want to steal the names `decode` and `encode` when
those are much more broad terms.

Other names such as `std::utf8`, `std::utf32`, `std::utf16`,
`std::wide_execution`, and `std::narrow_execution` are fairly specific to
the text domain and I don't see them clashing.

Names such as `std::rope`, `std::text`, and `std::text_view` will speak for
themselves. There are a few traits types that might be introduced to the
standard, but as far as I can tell none of these will clash either.

`std::uni` is an OK namespace for the unicode properties.

Regarding earlier points on what the standard does provide: the standard
needs to provide encodings for all the encoding types that are (currently)
pushed out by the standard, and nothing more. This includes: std::utf8,
std::utf16, std::utf32, std::wide_execution, and std::narrow_execution. The
standard should not vend any other encodings, but the Encoding and Decoding
interfaces should be standard -- much like Allocator -- that allows a user
to swap in their own class type and object that replaces the use of an
encoding in any interface / function standard templates provide. (Similar
to char_traits, except not as useless.) This means users can employ
whatever encoding or power they have under the hood and enjoy fast and
correct text processing so long as they follow the required semantics.

Note that we cannot only ship utf8 as an encoding, because the standard
already ships and acknowledges more than utf8 as one of the encoding for
string literals. It would be highly dysfunctional to have utf16 string
literals that the standard library itself cannot process in a reasonable
manner.

Received on 2019-04-12 16:02:19