Spring Switzerland GmbH 2000 User Manual

Page 7

Advertising
background image

This creates an SML session, and loads the program into the SML session.

6. Type

Ctrl-c Ctrl-s

to see the output from the SML session. The SML session will be in

a new window named

mosml

, as in Figure 4 on page 6.

7. Resize and move the Emacs window (as described in Section 3) to make the two Emacs buffers

gcd.sml

and

*mosml*

larger. You can left-click on the buffer you want active.

8. If the program has syntax errors or type errors, the SML session prints messages about them.

Use

Ctrl-c ‘

to move the cursor to the position where an error has been located (on PC’s

with danish key layout the character

is the upper case of the key

just to the left of the

backspace key). Edit the program to correct the errors. When you have finished correcting
the errors, go back to step 4 above. Typing

Ctrl-c Ctrl-b

again will load the corrected

program into the existing SML session, and SML prints the types of the functions and values
defined.

9. Select the SML session buffer

*mosml*

window by moving the mouse to the buffer and click

the left mouse button. Enter some expressions to test your program, for instance

gcd(34,2);

.

To go back to the SML program buffer (

gcd.sml

), move the mouse to the buffer and click the

left mouse button.

10. When you have finished editing and testing, terminate the SML session by typing

Ctrl-c

Ctrl-d

in the SML session buffer (

*mosml*

).

11. To print out the program or the output from the SML session, select the appropriate buffer and

activate

Print buffer

or

Postscript Print buffer

in the

Tools

menu (move the mouse to

Tools

at

the top of the window, press down the left mouse button, keep the button pressed down, move
the cursor to the wanted item, and release the button). The default printer is

p165

. To choose

another printer use the menu “Choose Printer” in the “Tools” menu.

12. To terminate Emacs, type

Ctrl-x Ctrl-c

or press the close button in the window (cf. Sec-

tion 3). If you have not saved your program file, it will ask “

Save file ...?

”, to which

you should answer “

y

”.

Key kombinations like

Ctrl-c Ctrl-b

for sending a program to the SML compiler are specific

for the sml mode of Emacs which is activated by the extension “

.sml

” of the file name. An overview

of these special functions can be found in the

Sml

menu (click on

Sml

in the Emacs window).

If you get into a mess with Emacs, try

Ctrl-g

once or twice to interrupt it. If this does not help,

type

Ctrl-x Ctrl-c

(or press the close button in the window) to terminate Emacs, and answer

any questions it asks.

6.1

SML system functions

This section describes a selection of built-in functions for controlling the Moscow ML compiler in
interactive mode.

7

Advertising