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 VAA11733; Fri, 6 Dec 2002 21:07:02 +0100 (MET) 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 VAA11776 for caml-list@pauillac.inria.fr; Fri, 6 Dec 2002 21:07:02 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA09721 for ; Fri, 6 Dec 2002 19:37:07 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from vendian.org (ediacara.ne.client2.attbi.com [24.128.96.133]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id gB6Ib6103479 for ; Fri, 6 Dec 2002 19:37:06 +0100 (MET) Received: (from mcharity@localhost) by vendian.org (8.11.6/8.11.6) id gB6Iehc17706; Fri, 6 Dec 2002 13:40:43 -0500 Date: Fri, 6 Dec 2002 13:40:43 -0500 Message-Id: <200212061840.gB6Iehc17706@vendian.org> To: caml-list@inria.fr Subject: [Caml-list] Exceptions and C From: Mitchell N Charity Reply-to: mcharity@vendian.org Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I rather expected this to raise an exception... $ cat test1.ml let plus_f x y = x +. y;; Callback.register "plus_f" plus_f;; $ cat test2.c #include #include #include #include int main (int argc, char **argv) { char * args[2] = { "fake_name", NULL }; caml_startup(args); { CAMLparam0(); CAMLlocal2(f,res); value the_args[3]; the_args[0] = copy_double(32.1); the_args[1] = copy_string("go boom"); /** incorrect type **/ f = *(caml_named_value("plus_f")); res = callbackN_exn(f,2,the_args); if(Is_exception_result(res)) { fprintf(stderr,"OCaml exception raised.\n"); exit(1); } fprintf(stderr,"No exception.\n"); fprintf(stderr,"%lf\n",Double_val(res)); } } $ gcc -c test2.c -I/usr/local/lib/ocaml $ ocamlopt test2.o test1.ml $ ./a.out No exception. 32.100000 But it doesn't. Any thoughts? I gather run-time type checking is not occurring. Can I at least count on avoiding a segfault, or is behavior completely undefined if callback arguments are incorrectly typed? Thanks, Mitchell Charity ------------------- 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