Logical const

Walter Bright newshound2 at digitalmars.com
Mon Nov 29 16:35:17 PST 2010


Fawzi Mohamed wrote:
> logical const is useful for lazy functions and memoization, and if 
> implemented correctly it is perfectly safe.
> As I said in an older discussions, to have it with the current system 
> all that is needed is some guarantees that the compiler will not 
> disallow "unsafe" changes (by moving to read only memory for example)in 
> some cases.
> For example casted mutable types, so that casting to mutable works.

D allows escape from the type system, but the programmer who does that loses the 
guarantees, and it's up to him to ensure that the result works.

String literals, for example, are going to often wind up in read only memory.


More information about the Digitalmars-d mailing list