string literals

bearophile bearophileHUGS at lycos.com
Fri Jan 25 03:23:23 PST 2008


Saaa:

>Then, how about adding the .access property to arrays? (or all types :) With strings default .access as read only?<

What's the .access property of arrays in the language you talk about?

If you want to try the D language, you may want to use the 1.x series instead of the 2.x that is alpha and has immutable strings.

Immutable things (like strings) are useful as AA keys too. In D 1.x (and Ruvy too, maybe) you can use a string as key, but if you later change that string its hash function isn't automatically recomputed, this leads to chaos. In Python you have both mutable and immutable arrays (called list and tuple), strings are immutable, but with the standard module "array" you can use mutable "strings" too. Python AAs called dict accept only their immutable versions to avoid those bugs (and inside tuples you have to put immutables).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list