From: Lars Christensen Date: 2001-08-16T17:40:19+09:00 Subject: [ruby-talk:19866] Re: The GUI poll is in, and the results aresurprising Only a couple of notes, because we basically agree :-) On Thu, 16 Aug 2001, Lyle Johnson wrote: > > E.g. to declare message identifiers: > > > > ID_CANVAS, ID_CLEAR, ID_LAST = enum(FXMainWindow::ID_LAST, 3) > > > > That is plain C++ style (or something) coding. Too many techinal > > detais (not VHLL). Why not the Ruby way?: > > > > identifier :ID_CANVAS, ID_CLEAR > > I see where you're coming from, but note that the message identifiers for > FOX aren't just randomly generated numbers. It is significant that when you > derive your class from (say) FXMainWindow, that your derived class's message > identifiers don't clash with those already defined in the base class; that's > why we usually start the numbering where the base class left off > (FXMainWindow::ID_LAST, or whatever). The toolkit may care about the values of the identifier, but the programmer shouldn't (he won't). The first think I did writing my hello world FXRuby script was to do this: module Fox class FXMainWindow def FXMainWindow.identifier(*symbols) instance_eval "#{symbols.join ', '}, ID_LAST = enum(Fox::FXMainWindow::ID_LAST, #{symbols.length + 1})" end end end It should be possible to generalize this code to other classes. > > @contents = FXHorizontalFrame.new(self, > > LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0) > > > > Yuck! What was that 5th zero about again? > > Most of the constructor arguments for FOX widgets are *optional* (with > reasonable default values). For the case you mentioned (FXHorizontalFrame), > only the first argument (the parent container widget) is required: > > @contents = FXHorizontalFrame.new(self) > > If some future version of Ruby supports keyword arguments, the situation > will be even better. Great! By why keep the arguments if you can do without them. When you use them, the expression becomes unreadable. You still won't be able to remember with the 5th argument was about. The only exception is the use of named arguments (by symbol or string, which is possible with today's ruby!): @button = Button.new('Click me', :border => 10); This is readable -- "Button.new('Click me', 10)" isn't. Is 10 the border? the font size? It becomes a short circuit in my brain rather than a short cut. > I think Ruby/GTK is a fine toolkit, too, but the Windows support (for GTK+ > itself, not the Ruby interface to it) seems to be a little shaky. A lot of > the non-"facts" about FOX and FXRuby that you stated in your post indicate > that you're not very familiar with it. Indeed I am not. I only spend 10 minutes looking over the samples (which DO use bad coding style :) and writing a simple hello world script. I wasn't trying to spread fud about FXRuby, but make a point about interfaces in general. It's good to hear the API design is of high priority in FXRuby! -- Lars Christensen, larsch@cs.auc.dk