Daniel Keep wrote: > Rainer Deyke wrote: >> As I understand it, D doesn't attempt to do general memoization anyway >> (and indeed, shouldn't). Given a reference to an object, if the >> reference itself is not modified from one dynamic cast to another, then >> the result of the former cast can be reused for the latter. > > Which is memoisation, more or less.
Memoization that can safely is safe for dynamic casts. > http://digitalmars.com/d/2.0/expression.html#DeleteExpression > > Doesn't actually specify whether this case is kosher or not. I suppose > that makes it undefined behaviour, although possibly not in quite the > same way. :) So you're deleting one object, leaving a dangling reference. You're creating a new object that by pure coincidence happens to be stored at the same memory address. Then you're dereferencing the original dangling reference, which by pure coincidence now points to the new object. How can this possibly be defined behavior? You're still dereferencing a dangling reference. -- Rainer Deyke - rain...@eldwood.com