http://qs1969.pair.com?node_id=417421


in reply to multiple method calls against the same object, revisited

In Perl 6 that's probably written like this:
given Gtk2::Window.new( "toplevel" ) { .signal_connect( :delete{ Gtk2.main_quit } ); .set_title( "Test" ); .border_width( 15 ); .add( given Gtk2::Button.new( "Quit" ) { .signal_connect( :clicked{ Gtk2.main_quit } ); $_; } ); .show_all; }
Though I could see extending the but operator to take a topicalized closure so we don't have to put the ugly $_ at the end:
Gtk2::Window.new( "toplevel" ) but { .signal_connect( :delete{ Gtk2.main_quit } ); .set_title( "Test" ); .border_width( 15 ); .add( Gtk2::Button.new( "Quit" ) but { .signal_connect( :clicked{ Gtk2.main_quit } ); } ); .show_all; }
Merry Christmas!!!