From: Damien Doligez <Damien.Doligez@inria.fr>
To: caml-list@inria.fr
Subject: Re: small code problem
Date: Thu, 8 Jul 1999 20:23:47 +0200 [thread overview]
Message-ID: <199907081823.UAA20553@tobago.inria.fr> (raw)
>From: "<Brad Knotwell" <knotwell@f5.com>
>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
next reply other threads:[~1999-07-08 23:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-08 18:23 Damien Doligez [this message]
[not found] <199907090927.KAA09195@toy.william.bogus>
1999-07-09 13:56 ` Gerd Stolpmann
1999-07-11 19:23 ` Markus Mottl
-- strict thread matches above, loose matches on Subject: below --
1999-07-02 22:30 <Brad Knotwell
1999-07-08 4:56 ` Markus Mottl
1999-07-08 22:49 ` Gerd Stolpmann
1999-07-09 0:27 ` <Brad Knotwell
1999-07-09 1:37 ` Fabrice Le Fessant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199907081823.UAA20553@tobago.inria.fr \
--to=damien.doligez@inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox