Pure dynamic casts?

Rainer Deyke rainerd at eldwood.com
Tue Sep 22 19:00:47 PDT 2009


Jarrett Billingsley wrote:
> Dynamic downcasts are not pure.

Actually they are.  Given an object 'o', 'cast(T)(<reference to o>)'
always returns the same value (either a reference to 'o' or 'null',
depending on class of 'o' and the value of 'T').

If the reference to 'o' is changed to point to a different object, then
the dynamic cast can return a different value.  This does not make the
dynamic cast impure, since you are passing in a different argument.

If the object 'o' is destroyed and another object is created at the same
physical memory location, 'cast(T)(<reference to o>)' can return a
different value.  This does not make the dynamic cast impure, since you
are passing in a (logically) different argument (which happens to use
the same physical representation).


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list