UPDATE: I surely do not intend to write something like my $error = 3.1415927->minus( 22->divide( 7 ) )->abs();. (Come on, BUK! even from you this example is quite polemic... ;-)

hmm some brainstorming

  • it's easier to read (and write)

     $ar->[$x][$y][$z]->push("element") than  push @{$ar->[$x][$y][$z]}, "element"

    The flow is in one left-to-right direction and doesn't jump around, the association is much more evident.

  • this clear association make it much easier to parse (statically) and to design help systems in IDEs, interactively popping up the documentation for a method.

  • method calls often allow cascading, like this enabling more expressive code.

  • from a learners and documentation perspective its much easier to check the method of an object than browsing through docs to find the function and search what it does combined with a special datatype.

  • it's easier to introspect (dynamically) which methods are possible for an object, even using a REPL which tab-expands to possible methods (that's really a powerful feature in the Python shell)

  • Extending new methods which only work with special data-types (like adding ruby's each-behaviour to arrays) is easier and cleaner than prototyping a function each() ¹)

  • it gets easier to port JS or Python code to Perl, strengthening the powerful future of our beloved language. ;)

  • look at the arguments from the Perl6 designers ...

  • TIMTOWTDI =)

    Cheers Rolf

    ¹) yes I know I could use "for", "each" was just an example, but please try to design a function which is restricted to arrayrefs, thats really far more complicated.

    UPDATE: corrected code and added further explanations in italics.


    In reply to Re^2: What are the drawbacks of autobox? by LanX
    in thread What are the drawbacks of autobox? 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.