Google

PLT MzScheme: Language Manual


Introduction

The core of the Scheme programming language is described in Revised5 Report on the Algorithmic Language Scheme. This manual assumes familiarity with Scheme and only contains information specific to MzScheme. (Many sections near the front of this manual simply clarify MzScheme's position with respect to the standard report.)

MzScheme (pronounced ``miz scheme'', as in ``Ms. Scheme'') is R5RS-compliant. Certain parameters in MzScheme can change features affecting R5RS-compliance; for example, case-sensitivity can be enabled (see section 7.4.1.3).

MzScheme provides several notable extensions to R5RS Scheme:

  • A module system for namespace and compilation management (see Chapter 5).

  • An exception system that is used for all primitive errors (see Chapter 6).

  • Pre-emptive threads (see Chapter 7).

  • A class and object system (see Chapter 3 in PLT MzLib: Libraries Manual).

  • A unit system for defining and linking program components (see Chapter 34 in PLT MzLib: Libraries Manual).

MzScheme can be run as a stand-alone application, or it can be embedded within other applications. Most of this manual describes the language that is common to all uses of MzScheme. For information about running the stand-alone version of MzScheme, see Chapter 17.

1.1  MrEd, DrScheme, and mzc

MrEd is an extension of MzScheme for graphical programming. MrEd is described separately in PLT MrEd: Graphical Toolbox Manual.

DrScheme is a development environment for writing MzScheme- and MrEd-based programs. DrScheme provides debugging and project-management facilities, which are not provided by the stand-alone MzScheme application, and a user-friendly interface with special support for using Scheme as a pedagogical tool. DrScheme is described in PLT DrScheme: Development Environment Manual.

The mzc compiler takes MzScheme (or MrEd) source code and produces either platform-independent byte code compiled files (.zo files) or platform-specific native code libraries (.so or .dll files) to be loaded into MzScheme (or MrEd). The mzc compiler is described in PLT mzc: MzScheme Compiler Manual.

MzScheme3m is an experimental version of MzScheme that uses more precise memory-management techniques. For long-running applications, especially, MzScheme3m can provide superior memory performance. See the compilation information in the MzScheme source distribution for more details.

1.2  Notation

Throughout this manual, the syntax for new forms is described using a pattern notation with ellipses. Plain, centered ellipses (···) indicate zero or more repetitions of the preceding S-expression pattern. Ellipses with a ``1'' subscript (···1) indicate one or more repetitions of the preceding S-expression pattern.

For example:

(let-values (((variable ···) expr) ···body-expr 
  ···1

The first set of ellipses indicate that any number of variables, possibly none, can be provided with a single expr. The second set of ellipses indicate that any number of ((variable ···) expr) combinations, possibly none, can appear in the parentheses following the let-values syntax name. The last set of ellipses indicate that a let-values expression can contain any number of body-expr expressions, as long as at least one expression is provided. In describing parts of the let-values syntax, the name variable is used to refer to a single binding variable in a let-values expression.

Some examples contain simple ellipses (...); these ellipses indicate that an unimportant part of the example expression has been omitted.

Square brackets (``['' and ``]'') are normally treated as parentheses by MzScheme, and this manual uses square brackets as parentheses in example code. However, in describing a MzScheme procedure, this manual uses square brackets to designate optional arguments. For example,

(regexp-match pattern string [start-k end-k]) 

describes the calling convention for a procedure regexp-match where the pattern and string arguments are required, and the start-k and end-k arguments are optional (but start-k must be provided if end-k is provided).