From: Xavier Leroy <xleroy@pauillac.inria.fr>
To: jharriso@ra.abo.fi (John Harrison)
Cc: caml-list@pauillac.inria.fr, jharriso@ra.abo.fi
Subject: Re: CAML Light system functions etc.
Date: Mon, 20 Nov 1995 11:16:47 +0100 (MET) [thread overview]
Message-ID: <199511201016.LAA07901@pauillac.inria.fr> (raw)
In-Reply-To: <199511191552.RAA18448@tanichka.abo.fi> from "John Harrison" at Nov 19, 95 05:52:27 pm
> (1) Is there an interface to "tempnam" or something similar? (For creating
> unique temporary filenames). I looked in the "unix" library but couldn't
> find anything -- I think it'd be a convenient addition.
It is a SMOP (Small Matter Of Programming). Here is the function I use:
let temp_file base suffix =
let rec try_name counter =
let name = "/tmp/" ^ base ^ string_of_int counter ^ suffix in
if Sys.file_exists name then try_name (counter + 1) else name
in try_name (Unix.getpid())
> (2) I'm not really convinced that integrating signal and exception handling
> is a good idea;
Signal handlers registered with Unix.signal are arbitrary functions;
They can raise exceptions, or do anything else a function can do.
However, it is true that there is only one way to abort other
computations from a signal handler, which is to raise an exception.
> it's neither pleasant nor efficient to always have to worry
> about signal exceptions popping up.
Shall I read this as ``I use (try ... with _ -> ...) all the time because
I'm too sloppy to figure out exactly which exceptions I should trap'' ?
That's a dangerous thing to do, since any heap allocation can trigger
the Out_of_memory exception.
> Is it possible to make SIGINT terminate
> the evaluation of the current toplevel phrase, without passing a signal
> exception to the currently executing function?
I'm afraid not. The language has only one non-local control structure:
exceptions.
> (3) Is there some hook to allow a user-defined function to be called after
> the evaluation and printing of each toplevel phrase? This would be nice for
> reporting run statistics etc.
No, there isn't.
Regards,
- Xavier Leroy
next prev parent reply other threads:[~1995-11-20 10:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-11-19 15:52 John Harrison
1995-11-20 10:16 ` Xavier Leroy [this message]
1995-11-20 12:04 ` John Harrison
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=199511201016.LAA07901@pauillac.inria.fr \
--to=xleroy@pauillac.inria.fr \
--cc=caml-list@pauillac.inria.fr \
--cc=jharriso@ra.abo.fi \
/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