Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: RFC: Class::Proxy::MethodChain

by adrianh (Chancellor)
on Feb 26, 2003 at 00:10 UTC ( #238620=note: print w/ replies, xml ) Need Help??


in reply to Re: RFC: Class::Proxy::MethodChain
in thread RFC: Class::Proxy::MethodChain

Personal taste - but I'd have the sub first to keep it like map, grep, et al.

sub apply_chain (&$) { local $_ = $_[1]; $_[0]->(); $_; } my $window = apply_chain { $_->signal_connect(delete => sub { Gtk->exit(0) }); $_->set_title("Test"); $_->border_width(15); $_->add( apply_chain { $_->signal_connect(clicked => sub { Gtk->exit(0) }); $_->show; } Gtk::Button->new("Quit") ); $_->show; } Gtk::Window->new("toplevel");


Comment on Re^2: RFC: Class::Proxy::MethodChain
Select or Download Code
Re^3: RFC: Class::Proxy::MethodChain
by Aristotle (Chancellor) on Feb 26, 2003 at 07:09 UTC
    The point of writing that function was that using map makes it read out of order - the new is at the bottom. Reversing the arguments on for_obj makes it practically the same thing as map so I would just stick with that one then.

    Makeshifts last the longest.

      Order is relative. Since everything else in perl that applies something to something else has the application block first that way reads more naturally to me in perl.

      To-mah-to. To-may-to. :-)

      Roll on perl6. With ~> and <~ and we can both be happy :-)

        Guess there's points to be made for either choice. It seems to be a matter largely of choosing between clear but verbose and concise but less obvious approaches.. the question is when verbosity detracts from clarity and when not - a choice that's probably going to be taken differently by every programmer. Well, given Perl 6 (pun intended), we won't have to choose.. now if only it was here.

        Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://238620]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-08-20 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (111 votes), past polls