Hi!
I agree with you. The one case where this syntax may be very useful is if
we want to implement class casting. So introduce a pair of magic methods
I do not think we want to implement class casting. I'm not sure how
class casting even makes sense - if the object is of one class, how can
you just make it into another class by casting? If you mean "casting"
actually returns another object of different class, then just make a
method for that that returns that object, I do not see how obscuring the
purpose of this operation with unobvious syntax would help.
The discussion is starting to drift very far from my original proposal.
Instead of trying to guess what I mean, can't people just refer to my very
simple definitive proposed behavior?
My proposal is simple: behave as an inline type hint. The same type hints
you have in arguments lists, but inline. The use case is "I want to make
sure this value is of this type" and a side benefit is the IDE can know the
variable is of this type too (for autocompletion purposes).
Whether they'd be exposed with the cast syntax or otherwise isn't that
important. Languages like ActionScript expose inline type validation both by
"static typing" hints and by "casting". In both cases the operation simply
validates the class can be seens as an instance of this class/interface.
Stan
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php