Dealing with Autodecode

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 1 05:14:06 PDT 2016


On 05/31/2016 08:46 PM, Walter Bright wrote:
> It is not practical to just delete or deprecate autodecode - it is too
> embedded into things. What we can do, however, is stop using it
> ourselves and stop relying on it in the documentation, much like [] is
> eschewed in favor of std::vector in C++.
>
> The way to deal with it is to replace reliance on autodecode with
> .byDchar (.byDchar has a bonus of not throwing an exception on invalid
> UTF, but using the replacement dchar instead.)
>
> To that end, and this will be an incremental process:
>
> 1. Temporarily break autodecode such that using it will cause a compile
> error. Then, see what breaks in Phobos and fix those to use .byDchar
>
> 2. Change examples in the documentation and the Phobos examples to use
> .byDchar
>
> 3. Best practices should use .byDchar, .byWchar, .byChar, .byCodeUnit
> when dealing with ranges/arrays of characters to make it clear what is
> happening.

(Shouldn't those be by!dchar, by!wchar, by!char? byCodeUnit and 
byCodePoint stay as they are.)

4. Rally behind RCStr as the preferred string type of the D language. 
RCStr manages its own memory, is fast, and has the right interface (i.e. 
offers several views for iteration without an implicit one, doesn't 
throw on invalid code points, etc).

This is the key component. We get rid of GC-backed strings, which is 
part of the crucial goal for D we need to achieve, and reap the benefit 
of a better design as a perk. Breaking existing code does not have the 
right benefit for the cost.

Let's keep the eyes on the ball, folks. We want to rid D of the GC. 
That's the prize.


Andrei



More information about the Digitalmars-d mailing list