Date: Tue, 15 May 2001 15:59:29 +0200 To: Benjamin Monate Cc: Sven LUTHER , lablgtk at kaba.or.jp Subject: Re: Galde support [was: Re: Accessing labels of GTree.tree_item] Message-ID: <20010515155929.A8545 at lambda.u-strasbg.fr> References: <20010511210045.3144e5bb.Benjamin.Monate at lri.fr> <20010514120202Z.garrigue at kurims.kyoto-u.ac.jp> <20010514131510.A3295 at lambda.u-strasbg.fr> <20010515181709D.garrigue at kurims.kyoto-u.ac.jp> <20010515113847.74211da1.Benjamin.Monate at lri.fr> <20010515145542.A7863 at lambda.u-strasbg.fr> <20010515153730.5c10e7da.Benjamin.Monate at lri.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20010515153730.5c10e7da.Benjamin.Monate at lri.fr>; from Benjamin.Monate at lri.fr on Tue, May 15, 2001 at 03:37:30PM +0200 From: Sven LUTHER Sender: Sven LUTHER On Tue, May 15, 2001 at 03:37:30PM +0200, Benjamin Monate wrote: > On Tue, 15 May 2001 14:55:42 +0200 > Sven LUTHER wrote: > > > i started looking into something like that a long time ago (in late 98 i > > think), but hadn't time for it then. Also at that time, glade would > simply > > overwrite the already written callbacks, which is not fine. What is the > > current situation on it ? > > Glade tries to merge the code for callbacks. When callback change name the > code is lost. > This is the same semantic in my "mlglade". > > Also it could be done much nicer in ocaml than what happens in C. You > could > > simply define the new interface as a functor from the set of callback > > functions to the interface, and let the user the responsability to fill > in > > this 'callback' module and apply it to the functor. What do you think > about > > this ? > > This could be interesting. You could also use a function that would take a > class of callbacks as argument. Yes, but this will not make things cleaner, i think. > If you generate only virtual method you get the same semantic as for the > functor. Orelse you can provide default values if you provide a class from > which a developper can inherit (this has some drawbacks). Yes, you can do lot of nice things in ocaml that you cannot do (easily) in C. > But : is this really useful ? Well, yes, i think so. it would be a nice way to separate the interface code from the code doing the real work. I know not everyone feels like doing this (especially people used to oo GUIs), but then maybe it is only the because they didn't have access to better ways. Also it would permit easier 'skinning', or let's say provide various GUI frontends to the same program ? you could even have a text only one. > This would increase the complexity of the generated code. Right now you By how much, and also by how much would it make the code cleaner, especially when writting bigger programs ? I do something similar myself, all by hand, and it seems nice to me. > just replace the body of the callbacks by whatever you want and you have a > running application. No special understanding of Gtk is needed, and very > elementary Ocaml code is enough to write an application. Same, same with the functor approach. And even less knowledge is needed, you don't even have to look at it. > On the other side, you may apply the functor many times with different > callbacks (using the "let module" construct). This could be useful. yes, and you could use the same callbacks with different interfaces, or even dynamically load either of them. (mmm, not sure it is possible, am not familiar with the state of dynamic linking in ocaml, but i guess you could do it with the standard dynlink library or some of the thirdparty solutions out there. > Could you argue about the drawbacks and good points of the functor/class > approach ? mmm, most good points are shown above, drawbacks are that you lose some efficiency by using functors, but i don't think this is important for a GUI. Also there can be some subtle type inference problems if you do some really complicated things ... mmm, if you wnat ot go that way, i would like very much to work with you on that. I have some experience of this kind of approach, and it interrests me well. Friendly, Sven Luther