Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

However, method chaining is completely counterintuitive, because it's not natural to have $object->make_head('larger') return the object with the head made larger. One would expect it, like most methods, to return true on success and false on failure.

Well, it does return true on success. And when you provide for method chaining you usually use exception handling and not inband error codes. As for indenting the chain, thats a matter of taste. All I know is that I sure am glad I can type:

print Data::Dumper->new([$foo],[qw(foo)])->Indent(2)->Purity(2)->Dump( +);

Instead of

print do{my $d=Data::Dumper->new([$foo],[qw(foo)]); $d->Indent(2); $d- +>Purity(2); $d->Dump()};

And any hard and fast rule that says I can't/shouldn't do the above I would reject as being utterly unworkable in practice.

As I said elsewhere in this thread, the probable and common usage case should be the deciding factor in how a given method behaves. One shouldn't have to contort oneself to fit into some arbitrary coding scheme when there is no reason to. The Perl motto for things like this is that easy things should be easy and hard things possible. Selecting a method design that meets these requirements is the only design criteria as far as I am concerned.

<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

In reply to Re: Re: object aggregators by demerphq
in thread chaining method calls by perrin

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (3)
    As of 2018-05-27 00:35 GMT
    Find Nodes?
      Voting Booth?