const?? When and why? This is ugly!

Sergey Gromov snake.scaly at gmail.com
Mon Mar 9 05:16:10 PDT 2009


Sun, 08 Mar 2009 19:24:32 -0700, Andrei Alexandrescu wrote:

> As far as signatures of functions in std.string, I agree that those not 
> needing a string of immutable characters should just accept in Char[] 
> (where Char is one of the three character types). That should make 
> people using mutable and immutable strings equally joyous.

So you agree that *the standard library* should avoid using immutable
when it's not strictly necessary after all.  This is quite in contrary
to what Walter says.  Now the question is, how any *other* libraries
differ?  I usually don't care about how you use immutable in your
personal code.  But if there is an XML library which takes immutables
everywhere,  it seriously limits my freedom in chosing my coding style.

Immutable string manipulation produces tons of garbage objects.  Every
time you want to replace '\\' with '/' you get garbage, if not as many
times as you encounter '\\' in the string.  This is something we avoided
at any cost in mobile Java games.  This is the attitude which makes
"large" Java applications so memory-hungry.  I have a hard time to
believe this magically became OK in D.



More information about the Digitalmars-d mailing list