Re: Missing __toString() part

From: Date: Sat, 03 Jun 2006 23:54:00 +0000
Subject: Re: Missing __toString() part
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-23895@lists.php.net to get a copy of this message
On Jun 3, 2006, at 6:12 PM, Jasper Bryant-Greene wrote:
I would imagine that __hash() or whatever it is called would be defined on all objects and implemented internally in PHP, and would simply generate some internal hash that is unique for all objects.
That might work for initial testing, but applying that sort of hash function to objects identified purely by strings, to take one example, doesn't work. (in_array(new Str("A"), array(new Str("A"))) is one failure mode that comes instantly to mind. It's inevitable that two non-identical objects would contain identical data. Think of the reasons behind C++'s operator==, or for those of you familiar with Carbon programming under MacOS, the hash callbacks provided by CoreFoundation's various container types. Gwynne SkyTag Software

« previous php.internals (#23895) next »