From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA20628; Wed, 22 Oct 2003 02:59:50 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA22516 for ; Wed, 22 Oct 2003 02:59:49 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h9M0xl109864 for ; Wed, 22 Oct 2003 02:59:47 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id JAA18061; Wed, 22 Oct 2003 09:59:41 +0900 (JST) To: rich@annexia.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] OCaml wishlist In-Reply-To: <20031021175006.GA9314@redhat.com> References: <20031021145531.GA14086@roke.freak> <20031021172812.GA26066@force.stwing.upenn.edu> <20031021175006.GA9314@redhat.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20031022095952N.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 22 Oct 2003 09:59:52 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 wishlist:01 jacques:01 gmain:01 gmisc:01 gmain:01 indentation:01 gmisc:01 indentation:01 jacques:01 ocaml:01 garrigue:01 garrigue:01 essentially:02 imperative:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Richard Jones > I'm really looking for help on this! My working theory at the moment > though is that writing UIs involves writing essentially imperative > code. One small example from some real code: > > let quit _ = > if !test_id = 0 then ( > GMain.Main.quit (); false > ) else ( > let icon = GMisc.image () in > icon#set_stock `DIALOG_QUESTION; > icon#set_icon_size `DIALOG; > let buttons = [ "Quit"; "Cancel" ] in > let ans = GToolbox.question_box ~title:"Quit" ~icon ~buttons > ("Are you sure you want to quit? This may lose any\n" ^ > "results from this assessment.") in > if ans = 1 then ( > GMain.Main.quit (); false (* User requested quit. *) > ) > else > true (* Don't close the window. *) > ) This is only a problem of indentation: let quit _ = if !test_id = 0 then (GMain.Main.quit (); false) else let icon = GMisc.image () in icon#set_stock `DIALOG_QUESTION; icon#set_icon_size `DIALOG; let buttons = [ "Quit"; "Cancel" ] in let ans = GToolbox.question_box ~title:"Quit" ~icon ~buttons ("Are you sure you want to quit? This may lose any\n" ^ "results from this assessment.") in ans <> 1 || (GMain.Main.quit (); false) Of course you have to be careful: you can shoot yourself in the foot with wrong indentation: let quit _ = let icon = GMisc.image () in if !test_id = 0 then (GMain.Main.quit (); false) else icon#set_stock `DIALOG_QUESTION; icon#set_icon_size `DIALOG; [...] In this case you're just going to jump over icon#set_stock... Jacques ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners