Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^5: RFC: Class::Proxy::MethodChain

by Aristotle (Chancellor)
on Feb 24, 2003 at 23:37 UTC ( #238294=note: print w/replies, xml ) Need Help??

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

I know it wasn't exactly a case of "once and only once", but that's the closest I could get to describe it. What I mean is that I found the previous code hard to read because of all the redundancy. There is a lot of repetition, but no so much that you could scan for patterns; reading the original-style code is downright painful.

And no, while my immediate concern is Gtk, the thoughts behind this run far further.

Ah, how I long for the beauty of saying something like

given(Gtk::FileDialog->new()) { .ok_button.label("Load"); .cancel_button.label("Exit"); .connect_signal(destroy => sub { ... }); # ... }

:-) That is really what I wanted to get out of this..

Wait.. I feel an idea coming on.. The problem with the for approach is that you need to weave calls; which is the case because you can't access the topic past the block. If for where an expression that could return something, it would work. One way to get that done would be to abuse map:

my $window = map { $_->signal_connect(delete => sub { Gtk->exit(0) }); $_->set_title("Test"); $_->border_width(15); $_->add(map { $_->signal_connect(clicked => sub { Gtk->exit(0) }); $_->show; $_ } Gtk::Button->new("Quit"); $_->show; } Gtk::Window->new("toplevel");
Now I'm not really sure if I should think of this as really clever or really evil.. *grin*

Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://238294]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2018-04-21 12:00 GMT
Find Nodes?
    Voting Booth?