Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run SML file but not be left in interactive mode

Tags:

windows

sml

I am using New Jersey SML on Windows. If test.sml is an SML file I can execute it by running this at a Windows command prompt:

C:\> sml test.sml

I then get the usual SML output and a new SML command prompt.

Standard ML of New Jersey v110.75 [built: Sat Sep 29 12:51:13 2012]
[opening hw1.sml]
val d2 = (1,1) : int * int
val d3 = (1,1) : int * int
val d4 = (2,1) : int * int
val d5 = (1,2) : int * int
val x7 = true : bool
-

What I would like instead is to be exited back to the Windows command prompt and not be left in the SML interactive mode.

How can I do this?

like image 383
rlandster Avatar asked Jan 19 '13 16:01

rlandster


3 Answers

Did you try:

sml <test.sml

Beyond that, using its compilation manager (CM) SML/NJ actually allows you to compile a program into binaries and run them separately. The manual should be able to tell you more (see especially section 15 describing the ml-build command).

like image 106
Andreas Rossberg Avatar answered Nov 15 '22 20:11

Andreas Rossberg


Also from the command line you can:

Ctrl - C interrupts (incase of loops that will not exit etc...)

Ctrl - Z exits the REPL

like image 23
Phill Cole Avatar answered Nov 15 '22 19:11

Phill Cole


Running SML/NJ that way, it will open the REPL (read-eval-print-loop). Thus it will wait for new declarations to interpret, until you tell it to exit.

Acording to the SML/NJ faq on usage, then

The OS.Process.exit function is the proper means of quiting sml from within a program.

It takes either OS.Process.success or OS.Process.failure as argument.

like image 5
Jesper.Reenberg Avatar answered Nov 15 '22 21:11

Jesper.Reenberg