string is rarely useful as a function argument
Timon Gehr
timon.gehr at gmx.ch
Sat Dec 31 13:45:27 PST 2011
On 12/31/2011 07:56 PM, Andrei Alexandrescu wrote:
> On 12/31/11 10:47 AM, Michel Fortin wrote:
>> This means you can't look at the frontUnit and then decide to pop the
>> unit and then look at the next, decide you need to decode using
>> frontPoint, then call popPoint and return to looking at the front unit.
>
> Of course you can.
>
> while (condition) {
> if (s.raw.front == someFrontUnitThatICareAbout) {
> s.raw.popFront();
> auto c = s.front;
> s.popFront();
> }
> }
>
> Now that I wrote it I'm even more enthralled with the coolness of the
> scheme. You essentially have access to two separate ranges on top of the
> same fabric.
>
>
> Andrei
There is nothing wrong with the scheme on the conceptual level (except
maybe that .raw.popFront() lets you invalidate the code point range).
But making built-in arrays behave that way is like fitting a square peg
in a round hole. immutable(char)[] is actually what .raw should return,
not what it should be called on. It is already the raw representation.
More information about the Digitalmars-d
mailing list