On 30 October 2014 10:40:10 GMT, Lester Caine <les...@lsces.co.uk> wrote:
>On 30/10/14 07:19, Will Fitch wrote:
>> The magic method is more of a PHP approach while an interface would
>be more appropriate.  That said, this RFC is a true representation of a
>hash vs something like spl_object_hash.  That’s what causes user
>confusion.  spl_object_hash would’ve been better served as a name like
>spl_object_id or spl_object_hash_id.  Something that indicates
>uniqueness regardless of the values of a particular object.
>
>The bit of the jigsaw I'm still missing here is just what the object of
>the exercise is?


There are many different use cases for hash keys, and PHP's "array" type is 
particularly flexible.

For instance, de-duplicating a list of items ($foo[$x] = $x), or counting 
occurrences of each ($foo[$x]++)

In the case of a simple DB model, the primary key value is the obvious choice 
for the hash key, but not all objects are as simple as that.

Being able to store the object itself would save having to recreate it from the 
key, e.g. looking the ID back up for a DB model, or re-parsing UTF8 for a 
UString.

Reply via email to