[MLton] using MLBs for scripting

Stephen Weeks MLton@mlton.org
Wed, 15 Sep 2004 13:02:42 -0700


MLBs are MLton's mechanism of describing whole programs and defining
and referencing libraries.  A script is a simple example of a whole
program that uses lots of libraries.  I was thinking it would make
sense, therefore, that we target MLBs as the scripting language for
MLton.  To do this, MLBs need to change to meet a requirement of
scripts: that they can be self contained in a single file.  Imagine if
one could write a script like the following.

----------------------------------------------------------------------
#!/usr/bin/mlton

$(MLTON_ROOT)/basis/basis.mlb

val () = print "hello\n"
----------------------------------------------------------------------

Once MLton has an interpreter with fast startup time (not for this
release, but surely the next one :-), MLBs seem like a very nice
scripting language.

To do this we need to figure out how to embed arbitrary SML code
within an MLB file.  This doesn't require any semantic improvements --
we already can do this by referencing an SML file.  We just need a
convenient syntax to do so.  It would be nice if it could be as easy
as in my example above, by adding the production 

	<basdec> ::= <program>   

to the MLB grammar, where <program> is from the SML grammar.

Thoughts?