Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Sys.argv with interpreter and compiler
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques GARRIGUE <garrigue@k...>
Subject: Re: Sys.argv with interpreter and compiler
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
> My explanation may probably be misconceived - maybe "interpreted" means
> "interpreted by the byte code interpreter" to you whereas I use "compiled"
> for byte code and native code and "interpreted" if I call the interactive
> toplevel with a file argument.

I had the same problem as you, and indeed find it disturbing.
Particularly, since there is no way to change the contents of
Sys.argv, this means that you cannot easily use the Arg module in a
caml script. Silly.

> 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?

That part is not really a problem.
ocaml does not need to be a code file. You can perfectly link it with
the -custom option.  This is actually what you do when you add the
Unix library, which is a minimum to write scripts...
I suppose this is Pierre did, and he never realized that there was a
potential problem here.

Actually I use this scripting approach when developping libraries:
this avoids having to compile small test examples.

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.

Regards,

	Jacques
---------------------------------------------------------------------------
Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
		<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>