> 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 :)


In reply to Re^3: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI ) by LanX
in thread Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI ;) by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.