From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 1E700BDCB for ; Wed, 31 Aug 2005 00:56:09 +0200 (CEST) Received: from smtp7.wanadoo.fr (smtp7.wanadoo.fr [193.252.22.24]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j7UMu8a6016431 for ; Wed, 31 Aug 2005 00:56:08 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0707.wanadoo.fr (SMTP Server) with ESMTP id AAFDA180008E for ; Wed, 31 Aug 2005 00:56:06 +0200 (CEST) Received: from [81.53.67.234] (ANantes-154-1-16-234.w81-53.abo.wanadoo.fr [81.53.67.234]) by mwinf0707.wanadoo.fr (SMTP Server) with ESMTP id 2B1A01800086; Wed, 31 Aug 2005 00:56:06 +0200 (CEST) X-ME-UUID: 20050830225606176.2B1A01800086@mwinf0707.wanadoo.fr In-Reply-To: References: <4311DA63.4010104@havenrock.com> <3d13dcfc050830001671d0974f@mail.gmail.com> <20050830141430.GA16012@furbychan.cocan.org> <200508301701.49824.jon@ffconsultancy.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Jon Harrop , caml-list@yquem.inria.fr Content-Transfer-Encoding: 7bit From: yoann padioleau Subject: Re: GUI for OCaml (was: Re: [Caml-list] Does LablTk have a future?) Date: Wed, 31 Aug 2005 00:49:05 +0200 To: Chris Campbell X-Mailer: Apple Mail (2.728) X-Miltered: at concorde with ID 4314E408.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 caml-list:01 labltk:01 api:01 snippets:01 api:01 ocaml:01 callbacks:01 widget:01 widget:01 nesting:01 nesting:01 vbox:01 hbox:01 lablgtk:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS autolearn=disabled version=3.0.3 >> >>> I'm not even sure what a "functional" API for a >>> GUI toolkit would look like. Ideas? Example code snippets? >>> In fact the API is already "functional" in some way, because in ocaml (as well as in perl, ruby, ...) you can pass closure as callbacks. This is something really great for GUI compared to langage like C where you have to separate the code responsible for creation of the widget from the code responsible for the action on the widget. Another point is that it is functional because you can compose the widgets together. You can nest them so the nesting of the code can be put in paralell with the nesting in the widgets. You can do build_app_widget(title: "myapp", (build_vbox (build_menu (build_item "File" callback:(fun () -> some_action)) (build_item "Close" callback:(fun () -> some_other_action) ... ) (build_hbox (build_canvas (... ) ... ) >> >> I think the GUI code should be split into definition (i.e. how the >> widgets are >> laid out) and execution (i.e. what functions are called for GUI >> events). The >> former should be functional in style because it is easier to write >> and more >> succinct and the latter should be imperative in style because it is >> essentially poking a state machine about. >> > > This sounds like QTk. It is a wrapper to Tk that uses records (tuples > and atoms are records in Oz) and call backs to implement the gui. > It's quite effective. In Oz, your example would look something like > this... (warning, last Oz use was a while ago) > > Qtk.build td(lr(label:"Search" text(handle: H)) > (lr(button(text:"Add" action:P) > > Where P and H are call back procedures. > From what I remember you can do exactly the kind of stuff you wrote with lablgtk quite easily. The only problem is that many times in H and P you want to modify the state of the widget (for instance modify the text in an entry) and in that case you have to name the widget with a let. > > Make it independant to a degree. Most GUIs offer the same > functionality anyway. > I agree. > > Chris > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >