> but to be slightly more constructive...
indeed! =)
> Writing foo($x,$y) as $x->foo($y) makes the first argument look special, where it is not for functions and multi-methods.
How is the first argument not special in the shown examples?
For instance does push @a, 3 change the first parameter.
Equally the ->cycle() example.
And how is the bind operator matches= $x=~ /regex/ not special in Perl?
Is it really better than @matches = $x->match(/regex/) ?
Though I agree that something like $y= $x->plus(5) breaks symmetry, but thats not my intention.
So in short: I think your critic doesn't apply to mutators, where the first arg IS special.
Additionally in cases where dereferencing is needed, this can significantly simplify the syntax (multiple nested curlies around HoAoH do not facilitate readability)
Anyway I don't claim it to be a full replacement of real autoboxing, holding the method in $variable namespace is - well - not "optimal".
And the fact that only scalars are allowed on LHS is also a limitation!
I hope it's obvious that "Yes we can!" and "How I finally learned to love ..." were ironic references.
I wanted to share and discuss this idiom, but I don't expect a Nobel prize for coolness like Obama or consider me half as genius as Dr Strangelove...
In this sense Hail! Mr President! xD
Cheers Rolf
( addicted to the Perl Programming Language)
update
> Common Lisp got this right.
Could you plz elaborate, I don't know Common Lisp, (only eLISP¹)!
Something like wrapper functions which check the type of the first argument (ref) and call a method
based on their own name (caller) are no problem in Perl.
footnotes
¹) mentioned to please Your Mother :)