Immutability by default [was: Re: Tidy auto [Was: Re: @disable]]
Walter Bright
newshound1 at digitalmars.com
Mon Jan 18 12:03:52 PST 2010
Leandro Lucarella wrote:
> Do you remember when people asked for default immutability? I do :)
Yes, but it would break every other line of code already written in D.
> I like the idea of making x := y an alias for immutable x = y (or even
> enum x = y). That would make this style much more attractive without
> breaking backward compatibility as immutable-by-default would do.
Actually,
const x = y;
is better than immutable, because if y is a T*, it cannot be implicitly
converted to immutable, while it can be implicitly converted to const.
More information about the Digitalmars-d
mailing list