D and Nim

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 4 20:54:21 PST 2015


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


More information about the Digitalmars-d mailing list