How To Use ML ============ ============ This is a small tutorial to how to use the standard ML of New Jersey. As with the now familiar MIT Scheme, you can enter expressions into the interactive system or load code from previously saved source files. Here is the content of the present tutorial. 1. Running the system 2. Interactive input 3. Interrupting compilation or execution 4. exiting an interactive session 5. loading ML source text from a file 6. Error messages For more information on the subject, see the "official" New Jersey "User's Guide" by AT&T Bell Laboratories. 1. Running the System ++++++++++++++++++ To run the system, just type "sml" at the Unix prompt. The top level of the interactive system will be prompted to you by a "-". This is the first input level. The secondary input level that is printed when your input is incomplete is prompted by a "=". To complete the input, type "return". To cancel your input, type the interrupt character, e.g. ^C (control-C). 2. Interactive input +++++++++++++++++ Your input to the top level interpreter should be terminated by a semi colon and carriage return to be evaluated by the system. The system then works in a manner similar to Scheme. Example are - 3+2 = ; val it = 5 : int - Here I completed my input after the secondary level prompt "=" by typing ";". - 7 div 4; val it = 1 : int - ((3*5)-(9-8)) div 4; val it = 3 : int - As you see, the type of the result is printed. Contrary to Scheme, ML is indeed a TYPED language. You can now use the variable "it" to refer to the value of the last top level expression evaluated. 3. Interrupting Compilation or Execution +++++++++++++++++++++++++++++++++++++ Typing ^C (control-C) or DELETE, you return to the top level, thus interrupting whatever else you were doing. 4. Exiting an Interactive Session ++++++++++++++++++++++++++++++ To exit from the system or to go back to a parent process from which sml was called, type ^-D (control-D) at the top level. 5. loading ML source text from a file ++++++++++++++++++++++++++++++++++ To load a file, use the function use: string -> unit as in, e.g. use "assignment1a"; The loaded files can also include some call of "use". 6. Error messages ++++++++++++++ Error messages are printed while compiling as in Scheme. An example is - if true then 5 true else 6; std_in:0.0-0.0 Error: operator is not a function operator: int in expression: 5 true This means that the faulty expression "5 true" in the standard input is not a function.