* CAML Light system functions etc.
@ 1995-11-19 15:52 John Harrison
1995-11-20 10:16 ` Xavier Leroy
0 siblings, 1 reply; 3+ messages in thread
From: John Harrison @ 1995-11-19 15:52 UTC (permalink / raw)
To: caml-list; +Cc: John Harrison
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]
A few quick questions about CAML Light:
(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.
(2) I'm not really convinced that integrating signal and exception handling
is a good idea; it's neither pleasant nor efficient to always have to worry
about signal exceptions popping up. Is it possible to make SIGINT terminate
the evaluation of the current toplevel phrase, without passing a signal
exception to the currently executing function?
(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.
Thanks,
John.
=========================================================================
John Harrison | email: jharriso@ra.abo.fi
Åbo Akademi University | web: http://www.abo.fi/~jharriso/
Department of Computer Science | phone: +358 (9)21 265-4049
Lemminkäisenkatu 14a | fax: +358 (9)21 265-4732
20520 Turku | home: +358 (9)21 2316132
FINLAND | time: UTC+2:00
=========================================================================
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: CAML Light system functions etc.
1995-11-19 15:52 CAML Light system functions etc John Harrison
@ 1995-11-20 10:16 ` Xavier Leroy
1995-11-20 12:04 ` John Harrison
0 siblings, 1 reply; 3+ messages in thread
From: Xavier Leroy @ 1995-11-20 10:16 UTC (permalink / raw)
To: John Harrison; +Cc: caml-list, jharriso
> (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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: CAML Light system functions etc.
1995-11-20 10:16 ` Xavier Leroy
@ 1995-11-20 12:04 ` John Harrison
0 siblings, 0 replies; 3+ messages in thread
From: John Harrison @ 1995-11-20 12:04 UTC (permalink / raw)
To: Xavier Leroy; +Cc: John Harrison, caml-list
| > (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:
Yes, I ended up doing something using the PID. But then most library
functions are a SMOP; it still seems reasonable to provide the ones that
users are going to need. At least you and I needed this one.
| > 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.
That's an all-too-accurate reading! Except that I could perfectly well have
a common exception "MYERR" and just use "try ... with MYERR(_) -> ...". I
wouldn't object to the extra typing, but I guess it would be significantly
less efficient. Is that true? I suppose I could try it and find out.
| > (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.
Well, since you excel at reading between the lines, you can read my question
as "what a great idea it would be to add some hook... wouldn't it?" My guess
is that it would be easy for a CAML-Light expert to add, since the
interpreter's read-eval-print loop itself seems to be written in CAML.
Cheers,
John.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1995-11-20 12:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-11-19 15:52 CAML Light system functions etc John Harrison
1995-11-20 10:16 ` Xavier Leroy
1995-11-20 12:04 ` John Harrison
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox