Why string alias is invariant ?

Janice Caron caron800 at googlemail.com
Thu Jan 31 10:22:22 PST 2008


On 1/31/08, Sergey Gromov <snake.scaly at gmail.com> wrote:
> If I were doing this in C by loading an entire file in memory, I would
> lowercase it in-place which is both faster and takes less memory.
> D should support such efficient solutions.

It does.

    char[] data = cast(char[]) read( "myfile.txt" );
    inPlaceLower(data);

Now all you have to do is write the function inPlaceLower(). :)

Presumably, what you really mean is that functions like inPlaceLower()
should be in Phobos. I won't argue with that, because I agree with
you. But the D language does not prevent you from modifying in place -
it only prevents you from modifying invariant data in place.



More information about the Digitalmars-d mailing list