$x = new Obj;
$y[$x]= 123;
That behaviour is going to be fun to document, and for people unfamilar
with it to find in the manual
-> php.net/array -> go to array syntax page -> read down to find about
objects as keys -> go to __toHash() page...
..whereas...
$x = new Obj;
$y[$x->toHash()]= 123;
they might have a chance to see instantly how that is supposed to work,
on the rare occasion that somebody needs this, is it really worth
building it into the langauge????
Regards
Alan
Andi Gutmans wrote:
Yep that is also a choice, although it can be advantageous to have an
automatic (a) which people just now works, always...
I don't think it's a critical problem because as you pointed out
people can deal with it, but I think it'd be nice to provide some
tools to make life easier.
At 06:01 PM 6/3/2006, Pierre wrote:
Hi,
On 6/4/06, Andi Gutmans <[EMAIL PROTECTED]> wrote:
> Generally I think it's a good thing to allow to use objects as array
> indexes. There are really two ways of doing it:
> a) Try and find a way to create unique ideas.
> b) Support __toString() and leave it up to the author.
I see a third choice, which I prefer:
c) leave the choice to the user, he knows better what to do with his
object (like implementing his own get(Hash|Key) method.
--Pierre
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php