Daniel Keep Wrote:

> 
> 
> Jason House wrote:
> > Dynamic casts are pure. They don't use global state, and have the same 
> > output for the same reference as input. Interestingly, dynamic cast results 
> > are independent of intervening mutable calls... So there's even greater 
> > opportunity for optimization.
> 
> What if the GC just happens to re-use that address for a different object?


I was thinking of that and tried to be careful with my wording. I guess I 
failed. Memoization can't occur, exactly for the reason you indicate. I was 
trying to say that for the life of an object, the type and type info is 
immutable. Since a dynamic cast only uses that immutable state, the return 
value does not change over the lifetime of the object. This could be used for 
optimizations above and beyond simple purity. 

Reply via email to