Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

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

Ugh. :-( Sorry, but I'm not going to be sticking stuff in UNIVERSAL:: willy nilly, particularly not to fix such a trivial complaint. You could put it in a different package and call it as in ->UTIL::invoke_methods() or something.

In terms of parameter format, your code is quite similar to my first attempt at multiple method calls against the same object (f.ex GUI programming). Putting the method name outside the list of parameters but it's awkward rather than convenient in practice. In my code I did it because I wanted to be able to represent sub-callchains as in

$obj->foo; $obj->child->bar; $obj->baz;

but it's still too limited anyway because you can't pass parameters to intermediate methods. Putting the methodname inside the arrayref actually allows for syntax to handle this. (You put nested arrayrefs in front of the name of the method to call, easily distinguished because the name must be a string.)

Another option might be something like

sub CHAIN::AUTOLOAD { my $self = shift; my ( $method ) = ( our $AUTOLOAD =~ /.*::(.*)/ ); $self->$method( @_ ); $self; } # now we can say my $window = Gtk2::Window ->new( "toplevel" ) ->CHAIN::signal_connect( delete_event => sub { Gtk2->main_quit } ) ->CHAIN::set_title( "Test" ) ->CHAIN::set_border_width( 15 ), ->CHAIN::add( Gtk2::Button ->new( "Quit" ) ->CHAIN::signal_connect( clicked => sub { Gtk2->main_quit } ) ) ->CHAIN::show_all();

but again, ugh.

Trust me, I've been around the block a number of times with this one. All of the “solutions” suck, the one in the root node just IMHO sucks a little less than all the others. We need Perl6.

Update: oh, and thanks for the heads up on $@!

Makeshifts last the longest.


In reply to Re^2: multiple method calls against the same object, revisited by Aristotle
in thread multiple method calls against the same object, revisited by Aristotle

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (13)
    As of 2014-07-22 10:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (109 votes), past polls