const?? When and why? This is ugly!

bearophile bearophileHUGS at lycos.com
Sat Mar 7 06:04:59 PST 2009


Walter Bright:

>The way to do strings in D is to have them be immutable. If you are building a string by manipulating its parts, start with mutable, when finished then convert it to immutable and 'publish' it to the rest of the program.<

Most of the times this seems acceptable.
But if such text is very long (example, 20 MB) and you want to pass it around for various functions to process&modify it, they you may want to keep it mutable (this is a quite uncommon situation, but it's happened to me, during genomic data processing).

Bye,
bearophile



More information about the Digitalmars-d mailing list