6.3 Let’s try SML# interactive mode
Include the SML# installation directory in your command load path, so that you can run SML# by the name smlsharp. When invoked without any parameter, SML# stars its interactive session by printing the following message and waits for your input.
$ smlsharp
SML# version 4.0.0 (2021-04-06) for x86_64-pc-linux-gnu with LLVM 11.1.0
#
The “# ” character is the prompt SML# prints. In this document, we write “$ ” for the shell prompt.
After this message, the compiler repeats the following steps.
-
1.
Read the user input up to “;”.
-
2.
Compile the input program and execute it.
-
3.
Print the result.
The following is a simple example.
# "Hello world";
val it = "Hello world" : string
The first line is the user input. The second line is the response of SML# system. As seen in this example, the compiler prints the result value with its type, and binds it to a name for subsequent use. If the user does not specify the name, the compiler uses “it” as the default name.