On Sun, 2014-10-26 at 23:36 -0700, Stas Malyshev 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. >
Morning Stas, True, I was just thinking that the next time we need to represent an object as a scalar for whatever reason we might end up having to add another magic method. It's easy enough to document that __toWhatever is used in the context we intend to use it in. Not super bothered about it ... it's obviously a +1 from me whatever the name. About restricting to signed/unsigned ints ... this doesn't seem sensible, the PHP programmer doesn't care about signs, or types. It makes sense to allow the programmer to return anything we would currently coerce to a valid key, don't think that needs to change. Cheers Joe -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php