The Status of Const
Jonathan M Davis
jmdavisprog at gmail.com
Fri Aug 13 14:09:04 PDT 2010
On Friday, August 13, 2010 13:37:09 Walter Bright wrote:
> There are many languages which support immutable - but it's hidden away in
> how they handle strings. For example, Perl has immutable strings.
>
> The great advantage to immutability (aside from threading) is that you can
> treat a reference type as if it were a value type. This is why so many
> languages treat strings that way. With D's immutability in the type
> system, rather than special cased for strings, is you can bring that
> advantage to any of your user defined types.
There are many languages which support immutable but few support it explicitly
(the most obvious cases where you have immutable are functional languages where
_everything_ is immutable), and I'm not aware of any other language that tries
to mix mutable, const, and immutable like D does. For that matter, const is a
bit of a rarity in my experience (though obviously there are some major
languages with it). It's more frequent that either all data is mutable, all data
is immutable, or most data is mutable with certain types being immutable
(generally in an implicit manner rather than explictly). So, D's attempt to mix
all of these options (on top of other stuff like shared) in an explicit manner
is, to my knowledge, unique.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list