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 UAA30941; Sun, 31 Mar 2002 20:04:47 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA28295 for caml-list@pauillac.inria.fr; Sun, 31 Mar 2002 20:04:45 +0200 (MET DST) 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 WAA07061 for ; Fri, 29 Mar 2002 22:00:42 +0100 (MET) Received: from zurich.ai.mit.edu (zurich.ai.mit.edu [18.43.0.244]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g2TL0fv25237 for ; Fri, 29 Mar 2002 22:00:41 +0100 (MET) Received: from neuchatel.ai.mit.edu (neuchatel.ai.mit.edu [18.43.0.29]) by zurich.ai.mit.edu (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id QAA06062 for ; Fri, 29 Mar 2002 16:00:41 -0500 Received: from attila by neuchatel.ai.mit.edu with local-esmtp (Exim 3.12 #1 (Debian)) id 16r3UH-00056e-00; Fri, 29 Mar 2002 16:00:41 -0500 Date: Fri, 29 Mar 2002 16:00:41 -0500 (EST) From: Attila Kondacs X-Sender: attila@neuchatel.ai.mit.edu To: caml-list@inria.fr Subject: [Caml-list] native-code and byte-code compiler differences Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk the following is a code segment that opens a window and if 'q' is pressed on the keyboard it closes it. It works with the byte code compiler fine but does not react to pressed keys when compiled with the native code compiler (using ocaml 3.04 for debian - from the unstable distribution). According to the ocaml manual this may happen if there is devision by 0 caught as an exception, or stack overflow, or if signal handling is involved. The first two cases are out of question here, and as far as I know reading mouse and keyboard events do not involve signals. So what's wrong here? and how can it be put right? here is the code: open Graphics;; let rec find_char_action_pair = fun pairlist (a:char) -> match pairlist with | hd::tl -> if (fst hd) = a then (snd hd) else find_char_action_pair tl a | [] -> (fun () -> ());; let map_keyboard = fun ?(mouse_action = (fun () -> ())) charactionlist -> let st = ref true in while !st = true do if mouse_action != (fun () -> ()) then (if (try button_down() with Graphic_failure _ -> (open_graph ""; button_down ())) then mouse_action ()); if key_pressed() then (match read_key() with | 'q' -> begin ((find_char_action_pair charactionlist 'q' )()); st := false end | a -> ((find_char_action_pair charactionlist a )())); done;; open_graph "";; map_keyboard [ ' ' , (fun () -> print_string "\n yes, it works!!")];; close_graph();; ------------------- 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