Hi! > Put another way, I think a key question here is: > > class Foo { > public $bar; > } > > $a = new Foo; > $a->bar = 'baz'; > $b = new Foo; > $b->bar = 'baz'; > > $arr[$a] = true; > $arr[$b] = true; > > > Does $arr now contain one value or two?
That depends on the semantics of class Foo. If Foo is something like UString, then it should contain one value, since UString is a value object (https://en.wikipedia.org/wiki/Value_object) - or at least it should be. However, if Foo represents something having separate identity - i.e. it's a Person class and 'bar' represents name - then of course it should contain two values, since the name is not the sole source of Person's identity. So the decision is on you as a programmer. And to give you the tool to make this decision and let PHP engine know about is exactly the point of this RFC. > If the desire is for it to contain 2, then spl_object_hash($a) already > has that covered, I think. > > If the desire is for it to contain 1, then the proposal sounds like a > way to normalize Foo::stringifiedValueObjectEquivalent(). You can describe it as such, but in a proper standartized way and with syntax that allows you to use same syntax constructs on all keys and not have to check each time if it's a special value and call a special function on it (same purpose as for __toString). -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php