Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
> 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-19 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found