Peter Alexander:

> If I give some const object to a function:
> 
> void render(const GameObject&);
> 
> GameObject obj;
> render(obj);
> 
> I can be sure that my object will come back unmodified.

render() is free to modify the objects contained inside GameObject, because 
that const isn't transitive.


> Yes, GameObject could be unreasonably mutilated by careless use of 
> mutable, but in practice that simply doesn't happen.

Likewise, in Python there is no const attribute, yet those program often don't 
have bugs.

The D transitive immutability is more rigid than the C++ const, it has a higher 
usage cost for the programmer, but it gives you back a stronger enforced 
semantics of immutability (strong enough for functional parallelism).

Bye,
bearophile

Reply via email to