On Monday, 16 November 2015 at 09:42:43 UTC, Ola Fosheim Grøstad wrote:
On Monday, 16 November 2015 at 09:04:33 UTC, Joseph Cassman wrote:
[...]

The D designers might want to look at Pony lang's capability system, which has been proven sound. It has 6 different aliasing capabilites that regulates among other things transition from mutable to immutable.

D is a little bit better of (if it does not allow casting away const) than C++, because in C++ const is essentially "shared const", whereas in D in is "local const with potential aliasing". AFAIK the D sementics is that no other thread can hold a mutable reference to something you have as const. But it is still a relatively weak guarantee. In C you have "restricted" for notifying the compiler that the resource is aliasing free within the context.

You described immutable, not const. If one thread has a const reference, it's entirely possible another thread has a mutable reference.

Atila

Reply via email to