Hello Andrei,
Friday, November 28, 2003, 1:59:35 PM, you wrote:
> On Thu, 27 Nov 2003, Marcus Boerger wrote:
>> helly Thu Nov 27 14:24:38 2003 EDT
>>
>> Modified files:
>> /ZendEngine2 zend_API.c
>> Log:
>> Convert objects to string if string is required by newer parameter parsing
>> since we do this for older parameter parsing does so too.
> Do you really think this is necessary? I can see the automatic > object->string casting being useful for things like print(), but when a > extension author expects a string, would it make sense to make the > object convert itself? I mean the result will most likely be some > internal object info represented as a string, and not something > meaningful.
No, when the object does not offer a valid string conversion nothing will change compared to what we had before. So the only thing done is that you now can implement objects that can be used as strings like simplexml_element. An extension like that cannot be programmed so elegant than without havin it. Besides that we convert all other types automatially whereever we are and objects offer an optional string conversion - so i thing we should use that where the conversion would have been applied for other types and where it makes sense - at least in the parameter parsing. If we don't do this i don't understant why we did such a complex conversion facility at all. Also i see confusion in the users. Why does print use conversion and sprintf not?
I disagree strongly. We will get ourselves into a nightmare by trying to automatically support __toString() in all sorts of places. We discussed this a long time ago and agree that __toString() will be only automatically called by print by using make_printable_zval() (some places such as backtrace can also call this).
The engine itself should not call __toString() automatically and people will have to use it the verbose way similar to Java.
Marcus, please revert any patches which have broken this direction. You shouldn't just commit this stuff without discussing it first.
Thanks, Andi
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php