> On 27 Oct 2014, at 06:36, Stas Malyshev <smalys...@gmail.com> wrote:
> 
> Hi!
> 
>> It seems __toScalar might be a good name, this is what the method
>> actually does, the engine then coerces to a type suitable for use as a
>> key, but you can return a double. It might be more forward thinking
>> therefore to use the name __toScalar, while today we'd only be using
>> it for this, 
> __toScalar does not express the fact why we are calling it - to use it
> as a key. It's not just a scalar conversion, it's conversion for the
> purpose of hashing.

It would also be used by Anthony’s Object Cast To Types 
(https://wiki.php.net/rfc/object_cast_to_types) RFC if revived, and __toScalar 
makes more sense there.

Personally, I think __toKey is best. It’s not a hash as such, it’s an 
equivalent string or integer key value. It fits nicely with __toString, and 
would fit with other __to* functions like __toInt if that RFC was revived. 
People would look at __hash and think it’s sql_object_hash, which it isn’t.

--
Andrea Faulds
http://ajf.me/





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

Reply via email to