[Dlang-study] [rcstring] Defining rcstring
code at dawg.eu
Sat Feb 6 06:31:44 PST 2016
On 02/02/2016 10:40 PM, Andrei Alexandrescu wrote:
> Hello everyone,
> * call it rcstring or RCString? The first makes it closer to "string",
> the other is politically correct.
You can defer that decision. I'd initially go w/ RCString and use
rcstring iff it becomes part of the language.
> * Characters are small so no need to return them by reference. Because
> of this, making RCString @safe should be possible in current D. However,
> this also makes RCString not a plug-in replacement for string (which may
> after all be a good thing)
> * Since string-compatibility is off the table, how about we fix string's
> issues with autodecoding? RCString should offer no indexed access and no
> length. Instead it offers the ranges byCodeUnit, byChar, byWChar, and
Please don't repeat the mistake and use byUTF!char, byUTF!wchar, and
> The first one does not do any decoding and offers length and
> random access. (What should be its element type?)
As byCodeUnit accesses the representation the element type of code units
should be unsigned integers.
ubyte <-> char
ushort <-> wchar
uint <-> dchar
> * Immutable does not play well with reference counting. I'm of a mind to
> reject immutable rcstring for now and figure out later how to go about
> it. Then const rcstring is okay because we always consider const a view
> on mutable strings (even though they're gone). We'll cast const away
> when manipulating the refcount.
Are you only talking about RCString itself or the underlying buffer?
It seems, that many languages choose immutable strings (the buffer),
would be good to get a better picture of different approaches
(immutable, mutable, CoW), how to construct immutable strings (first
build then freeze?).
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the Dlang-study