Phobos - breaking existing code
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Sun Nov 30 15:28:50 PST 2014
weaselcat:
> On Sunday, 30 November 2014 at 23:16:14 UTC, bearophile wrote:
>> ...
>> I suggested to make that variable i an immutable by default.
>
> I suggest everything be made immutable by default ;)
Currently D doesn't have a keyword as "mut" or "mutable" so if
you make the foreach variable immutable by default, you have some
troubles when (rarely) you want a mutable foreach index (you need
an auxiliary variable, and you have to type it manually, because
if you use "auto" you get another immutable again).
But for the general case of all the variables, this breaks all
the D2 code, so you can't do that (but I don't know why this
change wasn't done in the D1->D2 transition), and I think Walter
doesn't like things like pragma(strict) to be put beside the
module name to denote modules where variables are const/immutable
by default. So I didn't even discuss this impossible option.
Bye,
bearophile
More information about the Digitalmars-d
mailing list