Re: SimpleXML & Casting to String

From: Date: Sun, 29 Feb 2004 17:36:42 +0000
Subject: Re: SimpleXML & Casting to String
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-8257@lists.php.net to get a copy of this message
On Feb 29, 2004, at 12:31 PM, Andi Gutmans wrote:
At 12:20 29/02/2004 -0500, Sterling Hughes wrote:
On Feb 29, 2004, at 12:03 PM, Andi Gutmans wrote:
I think there isn't a problem with "echo" as it will call the string handler. However, in other cases it might be problematic. Maybe a solution is to implement an equals function so that people would do: if ($doc->name->equals("Hello")) ? I don't think we can support auto-string conversion transparently everywhere in the engine. print and echo are special cases and we also supported make_printable_zval() in PHP 4.
Well, the comparison operator should be overloaded if one of the objects is an overloaded object imho.
The problem is that user-land overloading can't be supported. C extensions might be able to be supported but I don't think it's a good idea to start hacking this into PHP. It wouldn't end at the comparison operator but people would want it to work everywhere.
I don't want user overloading - I've been consistently against that for objects of all types. I want it internally cause its important to be able to overload all operations for something like SimpleXML to properly work. The same applies to ext/mono (has the same issues as java, but even more due to field and property distinctions.)
My concern lies more with functions like utf8_encode() not properly getting the contents of the XML string - but I haven't looked into it too much - I'll try and get some hacking done on the cruise.
The way to do it today is to do a cast to (string) although I admit it's not a beautiful solution.
Right - what I don't understand is that why doesn't convert_to_string_ex() handle this? -Sterling

« previous php.internals (#8257) next »