Ferenc Kovacs wrote on 28/11/2014 13:51:
On Fri, Nov 28, 2014 at 2:14 PM, Sebastian Krebs <krebs....@gmail.com>
wrote:

2014-11-28 2:13 GMT+01:00 Bostjan Skufca <bost...@a2o.si>:

Hello everyone,

this is a proposal to add new function to PHP core: spl_object_id()


The story:
========
Recently I was debugging some larger libraries and sorely missed a
function
that would return an object ID. A function called spl_object_hash()
exists,
but it returns identical hashes for equal objects.

It returns unique IDs for existing objects. A hash is only reused only when
the corresponding object was removed by the GC earlier.
So actually asking me it makes more sense to "fix" the behaviour of
spl_object_hash(),

yeah, the more I think about it the more I feel that the current
implementation is just a landmine.

Is there any BC implication of changing the implementation? Or is it just that we don't know what the alternative should be?

Looking at the implementation of spl_object_hash() [1] it already uses Z_OBJ_HANDLE_P(obj) as part of the output, so presumably that isn't enough to guarantee uniqueness anyway? (Which then leads to the question of what the advantage of an spl_object_id() function would actually be, if it's *less* unique than spl_object_hash())

[1] http://lxr.php.net/xref/PHP_TRUNK/ext/spl/php_spl.c#756
--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to