Hi!
Why not a __cast($Type) magic function?
The interesting thing is that in the engine the object handler is actually:
typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type
TSRMLS_DC);
i.e. the handler is already generic, but implementation API isn't -
standard engine handler supports only IS_STRING (and IS_BOOL is a funny
way - objects are always true). In other words, extensions already can
do this, PHP programmer can't.
1) It's more self-explanatory to explicitly call the appropriate
converting method, enough with implicit madness!
This is probably the reason why the above was done - conversion to the
string representation is a very frequent action (especially in the Web
world where everything ends up being in the text page anyway ;) while
conversion to numeric types is very special case and very ambiguous, as
Etienne noted, and conversion to an array is also rather special case (a
lot of cases where array-like syntax is called for are served by
ArrayAccess).
--
Stanislav Malyshev, Zend Software Architect
s...@zend.com http://www.zend.com/
(408)253-8829 MSN: s...@zend.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php