On 7/10/12 10:22 PM, Walter Bright wrote:
On 7/10/2012 6:53 PM, Andrei Alexandrescu wrote:
On 7/10/12 9:14 PM, Walter Bright wrote:
Anyhow, the point of @trusted is to notify the maintainer that "here be
dragons".

I think that's not representing @trusted quite accurately. There's no
dragon
there. @trusted means "the code is correct but not mechanically
checkable".
Casting away const is NOT correct.

You're right in that it would break immutable args passed.

PIMPL is a better option.

I am pretty sure your approach with PIMPL is also undefined, so we may as well stop suggesting it as a viable possibility.

Consider:

immutable(T) t1 = create();
int x = t1.x;
const(T) t2 = t2;
t2.method();
assert(x == t1.x); // the compiler should be able to assume this

For the entire immutable thing to work, the compiler must have an iron-clad guarantee that transitively-accessed data members in t1 will preserve before and after the call to t2.method(). Your proposed cast, if ever defined, essentially breaks that guarantee. If that is down, the entire notion of immutable breaks down.

Please do not propose pimpl and cast anymore. This is important. Thanks.


Andrei

Reply via email to