On Dec 15, 2003, at 1:37 AM, Jon Parise wrote:
On Mon, Dec 15, 2003 at 01:32:57AM -0500, George Schlossnagle wrote:
Nope. How is it different or nicer than doing $defect->thrownException()->__toString()? It saves you 4 characters?
If it doesn't do anything 'magical', why bother with the __? If you always have to call it manually, it should be an interface:
interface Stringable { public function toString(); }
And that way extensions and user code both can decide if they want to give special treatment to objects that implement Stringable.
I think that's reasonable, although I think it's generally useful for all objects to implicitly implement 'Stringable' (in the same way that they all implement "Cloneable", via the __clone() method, today).
Well, the whole discussion (from my point of view) revolved around not wanting to cast objects to strings in arbitrary contexts, even if they had a __toString() method. You can use an interface to signify that not only do you implement the necessary helpers to represent yourself as a string, but also that that _is_ the behavior that you want, That seems useful to me (would solve Adam's problems, I think), but only if classes don't implement that by default.
George
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php