Version française
Home     About     Download     Resources     Contact us    
Browse thread
Scripting in ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin1977@l...>
Subject: Re: [Caml-list] Scripting in ocaml
On Thu, 21 Dec 2006, Richard Jones wrote:

> On Wed, Dec 20, 2006 at 10:41:20PM -0500, Denis Bueno wrote:
> > I've been writing bash scripts to perform various build- and
> > development-related tasks, and I don't enjoy it. I won't bore you with
> > detailed reasons why. The upshot is that I'd like to script in OCaml.
> >
> > I have considered writing a few camlp4 extensions to make it easier to
> > write scripts:
> >
> >  1) create a syntax which grabs environment variables:
> >
> >    e.g. $FOO would grab the value of the environment variable FOO
> >
> >  2) some sort of more convenient process interaction, e.g., for piping.
>
> I think it's a great idea - I'd love to push OCaml for scripting.
> However I hope your camlp4-fu is up to snuff.  You'd want, as you say,
> a syntax for pipelines and file redirection, but more importantly
> you'd want a very simple syntax for running commands.  So you can
> write some unholy OCaml/sh combination like:
>
>   let nr_files = int_of_string ` ls | wc -l `

It's something that I'd love to have too. An implementation of a
simple subset of sh would be nice. The programming features would be
handled by ocaml, so we need a way to use ocaml variables as
shell variables (of type string, string list or command) in addition to
environment variables.

Should camlp4's quotations be used for this, or should the special syntax
be handled by another preprocessor? I don't know.
A quotation looks like << ls | wc -l >> or <:cmd< ls | wc -l >>.

If something like this already exists, please let us know.
If not, I'd be glad to help design the thing.



Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr