From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA03772 for caml-redistribution; Fri, 9 Jul 1999 01:45:59 +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 UAA21961 for ; Thu, 8 Jul 1999 20:23:49 +0200 (MET DST) Received: from tobago.inria.fr (tobago.inria.fr [128.93.8.21]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id UAA28515 for ; Thu, 8 Jul 1999 20:23:47 +0200 (MET DST) Received: (from doligez@localhost) by tobago.inria.fr (8.6.10/8.6.6) id UAA20553 for caml-list@inria.fr; Thu, 8 Jul 1999 20:23:47 +0200 Date: Thu, 8 Jul 1999 20:23:47 +0200 From: Damien Doligez Message-Id: <199907081823.UAA20553@tobago.inria.fr> To: caml-list@inria.fr Subject: Re: small code problem Sender: weis >From: " >let usage = lazy (Printf.printf "Usage: %s file\n" Sys.argv.(0); exit ~-1);; >let filename = > try > Sys.argv.(1) > with Invalid_argument("Array.get") -> > Lazy.force usage;; > [knotwell@knotwell stock]$ ./a.out > Usage: ./a.out file The doc says Invalid_argument should be called, but it doesn't say anything about the string in the exception. On my alpha with the current development version of O'Caml, this is "Array.get" for the byte-code interpreter (which gives the expected result), but "out-of-bound array or string access" with the native-code compiler. The bug with uncaught exceptions seems to be architecture-specific, so you should tell us what kind of machine and system you have. >As an aside, I don't particular like my use of lazy and force. Is >there a cleaner way do the same thing? Certainly. Just write: let usage () = Printf.printf "Usage: %s file\n" Sys.argv.(0); exit ~-1;; let filename = try Sys.argv.(1) with Invalid_argument(_) -> usage ();; Better yet, use the Arg module to parse your command line... -- Damien