From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id LAA07987 for caml-redistribution; Mon, 20 Nov 1995 11:20:04 +0100 Received: (from xleroy@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id LAA07901; Mon, 20 Nov 1995 11:16:47 +0100 From: Xavier Leroy Message-Id: <199511201016.LAA07901@pauillac.inria.fr> Subject: Re: CAML Light system functions etc. To: jharriso@ra.abo.fi (John Harrison) Date: Mon, 20 Nov 1995 11:16:47 +0100 (MET) Cc: caml-list@pauillac.inria.fr, jharriso@ra.abo.fi In-Reply-To: <199511191552.RAA18448@tanichka.abo.fi> from "John Harrison" at Nov 19, 95 05:52:27 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > (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