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

Lars Ivar Igesund larsivar at igesund.net
Mon Apr 28 11:57:20 PDT 2008


Walter Bright wrote:

> Steven Schveighoffer wrote:
>> I agree that immutable strings can be valuable.  That's why I think it's
>> important to have a version of toupper that uses invariant strings
>> because
>> you can make more assumptions about when to make copies.  But why
>> shouldn't there be a version that does the same thing with mutable or
>> const strings? Why should a developer be forced to always use invariant
>> strings when the optimizations and multithreading benefits that come with
>> only using invariant strings may not be more important for a particular
>> program than
>> being able to modify a string?  I should still be able to use toupper on
>> mutable strings as well...
> 
> That's why I agreed with Janice on making a stringbuffer module that
> operates on mutable strings. It's easier than arguing about it, and it
> doesn't hurt to have such a package. And I suspect that after using it
> for a while, people will naturally evolve towards using all invariant
> strings.

After working with Java for quite some time, I have naturally drifted from
using invariant strings to stringbuffers.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango



More information about the Digitalmars-d mailing list