I think if we implement a way to get a hash from an object,
or at least
a unique identifier that can be used as a hash, then it should be
implicit just like other things are implicitly converted when the
context is clear. Of course, you should also be able to force it
explicitly. And I don't think there is any point in doing
this unless
we also implicitly go the other way. From unique identifier
to object.
As in:class foo { function bar($arg) { echo $arg; } }
$obj1 = new foo;
$obj2 = new foo;$a = array($obj1=>1,$obj2=>2);
foreach($a as $k=>$v) {
$k->bar($v);
}Unless this works, I am not sure there is any point to all
this. To me
the end goal is to make it possible to use types other than strings
and numbers as array indices which to me also means we should
look at doing
the same for arrays.
Thank you Rasmus, that was my exact concern too. Unless this works as you've specified, I'd be -1 for anything but explicit $a[(string)$b].
Cheers!
Mike
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm