- A common way to use sml is to use two windows, one for editing and one
for running the sml interpreter. The two most popular unix editors are
emacs and vi. You might want to consider pico if you want an editor that
is easy to learn.
- If you're going to use emacs, you'll want to have it go into "sml mode"
for files ending in ".sml". You do this by creating a file called
".emacs" (including the dot in the name) in your home directory. Take a
look at Stuart's .emacs file for an example (you can
save this in your home directory if you want).
- There is a utility program called rlwrap that you can access from the
341 class page that improves the interface to sml. Using rlwrap, you'll
get a history capability where you can use the arrow keys to go back to
previous expressions that you have entered. It also provides better "in
line" editing if you know emacs-style commands (e.g., ctrl-e to go to the
end of the line, ctrl-a to go to the beginning of the line). To use the
program, you would start up sml with this command:
/cse/courses/cse341/09sp/rlwrap sml
It is convenient to define this as an alias. The way to do this will depend
on your shell. To check, type "echo $SHELL". If your shell is.
- /bin/csh
- Create a file called ".myaliases"
- /bin/bash
- Create a file called ".bash_aliases"
Include this line in the file:
alias sml "/cse/courses/cse341/09sp/rlwrap sml"
if your shell is /bin/bash the command is only slightly different
alias sml="/cse/courses/cse341/09sp/rlwrap sml"
Then log out and log back in and you should find that you can say simply
"sml" to get the same behavior.
- You will find that sml doesn't print longer answers. For example, if a
list is long, it will print just the beginning part of the list and then
will use an ellipsis ("...") to indicate that there is more info that it
is not showing. You can override this by setting various environment
variables. The most important is "print.length". For example, you can
modify your alias to say:
alias sml "/cse/courses/cse341/09sp/rlwrap sml -Cprint.length=1000"
for bash
alias sml="/cse/courses/cse341/09sp/rlwrap sml -Cprint.length=1000"
Notice that the setting goes at the end of the alias.
- Another environment variable you might want to set is print.depth, which
determines how deeply ML will display nested structures like trees. It
is set in a similar manner, so you might modify your alias to:
alias sml "/cse/courses/cse341/09sp/rlwrap sml -Cprint.length=1000 -Cprint.depth=20"
and in bash
alias sml="/cse/courses/cse341/09sp/rlwrap sml -Cprint.length=1000 -Cprint.depth=20"