The Case Against Autodecode

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Sun May 29 04:00:38 PDT 2016


On 05/28/2016 03:04 PM, Andrei Alexandrescu wrote:
> On 5/28/16 6:59 AM, Marc Schütz wrote:
>> The fundamental problem is choosing one of those possibilities over the
>> others without knowing what the user actually wants, which is what both
>> BEFORE and AFTER do.
> 
> OK, that's a fair argument, thanks. So it seems there should be no
> "default" way to iterate a string.

Ideally there should not be a way to iterate a (unicode) string at all
without explictily stating mode of operations, i.e.

struct String
{
    private void[] data;

    CodeUnitRange byCodeUnit ( );
    CodePointRange byCodePoint ( );
    GraphemeRange byGrapheme ( );
    bool normalize ( );
}

(byGrapheme and normalize have rather expensive dependencies so probably
better to provide those via UFCS on demand)


More information about the Digitalmars-d mailing list