Browse thread
Re: Sys.argv with interpreter and compiler
- Markus Mottl
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Markus Mottl <mottl@m...> |
| Subject: | Re: Sys.argv with interpreter and compiler |
> > 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... Best regards, Markus -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl