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

Walter Bright newshound1 at digitalmars.com
Mon Apr 28 11:40:05 PDT 2008


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.



More information about the Digitalmars-d mailing list