2. Library and Environment Changes

Probably the preponderance of the effort of porting code to SML '97 involves updating references to identifiers from the top level environment and other references to the built-in Basis library. The Basis Library is documented separately, but we will cover some highlights of the changes in this section.

The SML/NJ Library has also been updated. New documentation for the SML/NJ Library is in preparation, but there is a SML/NJ Library Porting Guide that gives a module-level summary of the changes relative to the 0.3beta version of 1994. It lists name changes, deletions, and additions in the library relative to the 0.3beta release from 1994. This Porting Guide is also found in the smlnj-lib source directory in the file named PORTING. For documentation of the library signatures, see the comments in the source files for the various signature modules (e.g. src/smlnj-lib/Util/hash-table-sig.sml).

For a concise summary of changes in the top level environment, see the Top Level Environment Comparison page.

2.1.1 Arithmetic

2.1.2 Characters and Strings

A new character type has been added. Characters are no longer denoted by strings of length one. When you explode a string, you get a list of characters, not single character strings.

Character Literals (#"A")

Functions explode and implode

Character classifiers (e.g. isAlphaNum)

Turning a character into a string, and vice versa


2.1.3 Lists

foldl, foldr replace fold, revfold, and their types are different from those of fold, revfold.

A bunch of new functions.

Some functions that were bound at top-level are not in SML '97. (exists)

ListPair structure (zip, unzip, map, app)

2.2 Input/Output

2.2.1. TextIO

outstream => TextIO.outstream
instream  => TextIO.instream
input     => TextIO.inputN
output    => TextIO.output
std_out   => TextIO.stdOut
std_in    => TextIO.stdIn
- TextIO.output(TextIO.stdOut, "abc\n");
val it = () : unit

2.2.2. The print function

val print : string -> unit
Not overloaded now. Still bound at top level.
  print 3  => print(Int.toString 3)
  print 3.0 => print(Real.toString 3.0)
[see TextIO structure, IMPERATIVE_IO signature]

2.3. System Facilities

2.3.1. Invoking the compiler

  • use : string -> unit
    (bound in top level; alias for Compiler.Interact.useFile)
  • Compiler.Interact.useStream : TextIO.instream -> unit
  • 2.3.2. OS structure in Basis

    2.3.3. Posix structure in Basis

    2.3.4. The Unix structure

    2.4. SML/NJ Facilities

    2.4.1. The SMLofNJ Structure

    2.4.2. Useful control flags

    Controlling compiler warning messages.

    Dave MacQueen
    Last modified: Tue Mar 24 17:20:26 EST 1998