Pure dynamic casts?

Rainer Deyke rainerd at eldwood.com
Tue Sep 22 20:37:29 PDT 2009


Daniel Keep wrote:
> On the basis of how I understand pure to be implemented in D at the
> moment, it is impure.  Purity only considers the bits passed on the
> stack.  If the reference points to the same location in memory, it's
> considered the same argument.

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.  The
existence of the reference prevents the object from being
garbage-collected, and manual deletion results in undefined behavior.



-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list