From: Markus Mottl <firstname.lastname@example.org>
Subject: Re: Sys.argv with interpreter and compiler
To: email@example.com (Jacques GARRIGUE)
Date: Fri, 2 Jul 1999 09:56:04 +0100 (MET DST)
In-Reply-To: <19990702103052J.firstname.lastname@example.org> from "Jacques GARRIGUE" at Jul 2, 99 10:30:52 am
> > As far as I remember, making OCaml (at least under Unix) a "true"
> > scripting-language (=with human-readable "#!"-scripts) is not so easy to
> > achieve: only binaries may be used as interpreters of "#!"-scripts, which
> > is not currently possible with the way the toplevel "ocaml" is designed -
> > it needs to be a byte code file. Are there already any convenient ways
> > around this problem?
Sorry for that (it was well past midnight when I wrote this). It is of
course possible to make a binary version of the toplevel with "-custom"
- I mixed this up with the debugger, which exists as byte code version
only. It didn't even come to me to try the "#!"-version (!?). Maybe I
should stop going to bed this late...
The problem with the argument vector still remains, of course: instead
of the script name, the path to the toplevel is given on index 0.
> For scripting, there is however another potential problem: if your
> script becomes a bit long, you should really think about compiling it,
> typechecking becoming slow. The multiple VM is useful then.
Another solution would be to make parts of the file which hardly change
a separate module, compile them to binary code and link them with
the toplevel. So only the parts that are considered more "volatile"
stay in the script.
The possibility to generate one's own "interpreter" is really a very
interesting feature of OCaml. Thus, one can nearly arbitrarily speed up
scripts by linking more and more parts with the toplevel...
-- Markus Mottl, email@example.com, http://miss.wu-wien.ac.at/~mottl
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET