Received: Thu, 8 Apr 2004 04:46:10 +0900 And lo, Hal wrote: > Short constructor: > > b1 = button "Label" { do_this_when_clicked } > > Adding more stuff: > > b1.setup do > (right click, mouseover, etc can be set here too) > end > > The principle to me is: Make the most commonly occurring case the > easiest and shortest, but keep the other stuff possible. My own reasoning was - keep all the setup stuff inside the button { ... } constructor. Both do have strong arguments. > BTW, I normally prefer do/end for multiple lines and {} for single > lines. But that's just me. Same difference. When it comes to most programming, I use do ... end for in order logic, and {} for out of order logic. x.each do ... end 1.upto(5) do ... end x = lambda { ... } signal_connect { .. } Thread.new { ... } But coding using the EzGtk example doesn't feel so much like a program, as describing a layout for something. Feels like writing for a different purpose, even though it /is/ just typical ruby code. They read to me like: main do # main does: vbox do # vbox does: end end compared to: main { # Inside of main ... vbox { # inside vbox inside of main } } But like you said, same difference. Hopping back to an earlier topic - You were confused about Thread.current["storefunc"] = ... What I meant by this: 1) I'm not too big a fan about needing a different class or function for each EzGtk window, or even needing an EzGtk window. This means the functions would need to be independent of instances or classes, but as they still need a variable, the best solution I can see is a thread-level stack variable. It's doable by passing the "storefunc" to the block, but then it's not so "Ez". ie: require 'EzGtk' && include EzGtk mywindow = window { .. } myotherwindow = window {..} 2) So it doesn't require defining a new child of EzGtk Either done with a class variable on class Object, as it is above, or use a global. But using either isn't thread-safe, so Thread.current["storefunc"] would be thread safe. - This is also, as the website 'Its me' pointed out, a dynamically scoped variable. So to accomplish (1), I'd just need to change my code to do this: holdfunc = Thread.current["storefunc"] Thread.current["storefunc"] = lambda { ... } yield thewidget Thread.current["storefunc"] = holdfunc Tada! Thread-safe, and people can now just call mywin = EzGtk.window { EzGtk.vbox {..} }, or include EzGtk and just call window { vbox { } } - independently for each window they want to make. - Greg Millam