August Karlstrom
August Karlstrom

Reputation: 11377

How do I run freestanding scripts with SML/NJ?

How do I use SML/NJ to run a script which reads from STDIN and writes to STDOUT say? Is there a way to get rid of the output from the interpreter itself?

Upvotes: 4

Views: 710

Answers (1)

Gian
Gian

Reputation: 13945

Just to be very clear, SML/NJ is not strictly an interpreter. It's a compiler that just so happens to have a REPL. The best way to achieve what you're suggesting is to create a heap image (basically a compiled binary that's ready to be loaded by the SML/NJ runtime system), and then run it directly using sml @SMLload=heapfile.img where heapfile.img is the name of the heap file you generated. You might also want to pass @SMLquiet as a command line option. This will surpress any output while loading the heap file.

You might also just be trying to compile a program into something you can run stand-alone, in which case you might like to look at the MLton compiler.

Upvotes: 3

Related Questions