Re: New function: spl_object_id() or spl_object_handle()
| From: | Bostjan Skufca | Date: | Sat, 29 Nov 2014 18:04:00 +0000 |
| Subject: | Re: New function: spl_object_id() or spl_object_handle() | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79310@lists.php.net to get a copy of this message | ||
On 29 November 2014 at 00:21, Rowan Collins <rowan.collins@gmail.com> wrote:
> On 28/11/2014 01:13, Bostjan Skufca wrote:
>>
>> A function called spl_object_hash() exists,
>> but it returns identical hashes for equal objects.
>
> In case it's been lost in the noise, no it doesn't.
Ouch. I am terribly sorry about this mistake, it really does not.
However, having word "hash" in the function name suggests that
returned hash is generated by the object's contents, too. I just
noticed that the first comment explains that this is not the case,
which I confirmed with additional testing.
To quote a part of first sentence of Wikipedia on "Hash function":
"...with slight differences in input data producing very big
differences in output data."
So, to sum it up: spl_object_hash indeed does what I initially
required, but I was mislead by the "hash" word in its name, and the
environment where I was trying to use it (unable to bring two object
references in the same place easily).
But I would maybe suggest changing the name to spl_object_id (and
keeping ..._hash alias for backward compatibility).
b.