Stanislav Malyshev wrote: >> Yes, but it is already possible to call an object's method in array key >> context, so in combination with an appropriate interface the same can be >> accomplished. > > No, it's not possible. It is possible to call object method in an > expression, and then use the result of the expression as an array key. > But to do that you'd have to check that you're dealing with the object > and the call the special method.
Sorry for expressing myself imprecisely. Thanks to Rowan this is hopefully clarified now, see <http://marc.info/?l=php-internals&m=141882255826352&w=2>. > Looks like you don't understand why PHP has magic methods - since your > argument applies to every one of them. Why have __toString if you can > just call object method? Why have __call if you could just check if > method exists and call a special method if it doesn't? Why have __isset > if you could just call special method on an object and pass it the > property name? Of course, it's "just sugar". All programming languages > are "just sugar" by that definition. I'm neither arguing against having magic methods and other (syntactic) sugar in general, nor against having __hash() or __toKey() in particular. It's perfectly fine for me, if the RFC passes. >> I didn't mean to argue against the RFC, but merely wanted to point out >> that one could have object hashes without the proposed magic method >> (albeit in a more contrived way). > > You could have *everything* in a more contrived way. PHP 2 was Turing > complete, I am sure. Were we just wasting time these last 15 or so years > because everything was done in PHP since then was already possible, > albeit "in a more contrived way"? Or maybe there's some value in making > the ways significantly less contrived? IMO, that's the whole point of > what we're doing here. I do really appreciate your work, and I enjoy having a more expressive language. I justed wanted to point out Guilherme's apparent misinterpretation of your RFC, see <http://marc.info/?l=php-internals&m=141882026225496&w=2>. -- Christoph M. Becker -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php