Immutability by default [was: Re: Tidy auto [Was: Re: @disable]]

Pelle Månsson pelle.mansson at gmail.com
Tue Jan 19 13:51:11 PST 2010


On 01/19/2010 04:56 PM, Adam D. Ruppe wrote:
> On Tue, Jan 19, 2010 at 11:52:16AM -0300, Leandro Lucarella wrote:
>> I think he includes D1 code, which would be harder to port to D2. Makes
>> sense to me, that's why I think introducing the := operator as an alias to
>> immutable/const would be a good compromise. It makes extremely easy to use
>> immutable/const variables while keeping backward compatibility.
>
>
> Would this be a realistic fear with it?
>
> receiver := 1;
>
> reciever := 2; // meant to rebind, but spelling error goes unnoticed by compiler
>
>
> If so, bah. Of course, I like it how it is now anyway.

Python, and most other dynamic languages, have that problem. They are 
not suffering because of it.

Also, const cannot be rebound.



More information about the Digitalmars-d mailing list