English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 1999-07-02 (00:40)
From: Pierre Weis <Pierre.Weis@i...>
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?
> Using byte code for scripting is not so comfortable and I think that
> OCaml would give a wonderful language for "true" scripting...

I use a very simple way to achieve this: just tell the unix system to
execute the right ocaml interpreter, then I execute the file as

For instance:

pauillac:~$ cat > essai

print_string "Hello world!"; print_newline();;
exit 0;;
pauillac:~$ chmod a+x ./essai
pauillac:~$ ./essai
Hello world!

Normally I use a special version of ocaml, with the regexp and unix
libraries linked, but it's the idea: just write plain caml code and
interpret it ! In many cases it is fast enough for what I need!

What do you think of this completely interpreted approach ?

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/