Hi,

Le 16 déc. 2014 13:45, "Rowan Collins" <rowan.coll...@gmail.com> a écrit :
>
> Patrick Schaaf wrote on 16/12/2014 11:46:
>
>> Am 16.12.2014 12:36 schrieb "Matteo Beccati" <p...@beccati.com>:
>>>
>>> On 16/12/2014 11:52, Andrea Faulds wrote:
>>>>
>>>> I was previously in favour of this, but it’d prevent actual indexing
>>>> by objects in future, and I can’t think of any use cases which aren’t
>>>> better solved by explicitly converting to a string/integer.
>>>
>>> That's precisely the same reason why I voted Nay. And I wouldn't have
>>
>> been able to put it down in words better than Andrea did.
>>
>> That was my thought initially, too. But I think it is wrong. If PHP ever
>> gets around to provide objects-themselves-as-array-keys support, it can
>> easily do that
>>
>> 1) only if the object does not have such a __toKey() method, or
>> 2) if the object has one, but it returns the object itself (which is
>> forbidden now by the RFC)
>
>
> Hm, that's an interesting thought. My thought had been that an
object-as-key would need to specify its hash anyway, so that two objects of
the same "value" would be automatically de-duped, just as two strings are.
But I guess an internally unique handle for the specific object would also
be a reasonable approach for some uses.

Just a random thought: the `__hash` method can just `return
spl_object_hash($this);` to have an object id.

> --
> Rowan Collins
> [IMSoP]
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Cheers,
Florian Margaine

Reply via email to