D and Nim

Ary Borenszweig via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 4 21:12:35 PST 2015


On 1/5/15 1:54 AM, bearophile wrote:
> Vlad Levenfeld:
>
>> Can the compiler automatically make variables immutable if it can
>> prove that they are never changed in some code?
>
> This is very different from what I am saying. The C compilers don't go
> to add a "const" annotation to your source code (but perhaps the Rust
> compiler warns about mut variables that don't get mutated).
>
> Inferring that a D template function is pure because it contains no side
> effects is not the same thing as stating it is pure in the source code.
> In the second case you get an error if you try to print from the
> function, it's part of the function contract.
>
> Bye,
> bearophile

Are there proofs of percentage of bugs caused by incorrectly mutating 
variables that were supposed to be immutable? I don't remember having 
such bug in my life.


More information about the Digitalmars-d mailing list