Is all this Invarient **** er... stuff, premature optimisation?

Janice Caron caron800 at googlemail.com
Mon Apr 28 06:57:11 PDT 2008


2008/4/28 Steven Schveighoffer <schveiguy at yahoo.com>:
>  > I have some strings read in from external source that I need to convert to
>  > uppercase. A quick look at Phobos and I find std.string has a toupper
>  > method.
>  > <very good example case removed>
>
>  This is all not an issue if Walter adopts 'scoped const' contracts.

toupper() couldn't be reused for all constancies, because the
invariant version should employ copy-on-write, wheras any other
versions would not be able to do this.

That is,

    toupper("HELLO");

can return the original, if and only if the string is invariant.



More information about the Digitalmars-d mailing list