@Mark Randall <mar...@gmail.com> > It keeps coming back to the feature we've all been praying to the PHP > Gods for... generics. > $x = cast<App.Object>($obj);
I did not think about using generics for this, but indeed this could work. It's only reasonably verbose, easily implemented in userland, and should be usable both by static analysis tooling, and potentially by the VM and JIT for future optimizations. It just costs an extra function call vs. a single opcode, but overall I could be OK with this approach. I'm not sure why generics haven't yet gained traction though, so unless there's a hope to see them implemented soon, I'll keep focusing on this standalone feature for now! - Ben