Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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]
[1nickt]: you are missing an entire element, which is that your base ticket price only gets you a middle seat. If you want to be window or aisle you must pay, or gamble that you'll be assigned there at ...
[1nickt]: ... flihght time (hoping that not enough others have paid and there are some "good" seats to be allotted.
[1nickt]: And this is in addition to paying extra if you want to be in the first 12 rows, or in the emergency exit row.
choroba was once seeted besides a guy that was so fat he was almost squished between the guy

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2017-12-18 13:42 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (486 votes). Check out past polls.