Scheme was introduced in 1975 by Gerald J. Sussman and Guy L. Steele Jr. [23,24], as the first dialect of Lisp to fully support lexical scoping, first-class procedures, and continuations. In its earliest form it was a very small language intended primarily for research and teaching, supporting only a handful of predefined syntactic forms and procedures. Scheme is now a complete general-purpose programming language, though it still derives its power from a small set of key concepts. Although early implementations of the language were interpreter-based and slow, some modern Scheme implementations boast sophisticated compilers that generate code on par with code generated by the best optimizing compilers for lower-level languages such as C and Fortran.
This book is intended to provide an introduction to the Scheme language but not an introduction to programming in general. The reader is expected to have had some experience programming and to be familiar with terms commonly associated with computers and programming languages. The author recommends that readers unfamiliar with Scheme or Lisp also read The Little Schemer [10] to become familiar with the concepts of list processing and recursion. Readers new to programming should begin with an introductory text on programming, such as Structure and Interpretation of Computer Programs [1], Scheme and the Art of Programming [21], or The Schematics of Computation [17].
This book is not a formal language definition or standard document and is not intended for use as such by implementors of Scheme. The "IEEE Standard for the Scheme Programming Language" [15], describing the ANSI/IEEE Standard for Scheme, is such a document. A separate series of documents, the "Revised Reports on the Algorithmic Language Scheme," contain extensions to the standard dialect that are not formally standardized but which most implementations support. Some of these extensions may be formally standardized at some future date. The current report in this series is the "Revised4 Report on the Algorithmic Language Scheme" [4], although as this book goes to press, there is already agreement on features to be included in the Revised5 Report.
In spite of the foregoing statement that this book should not be taken as a language definition, it does describe all of the language features documented in the ANSI/IEEE Standard, the Revised4 Report, and the forthcoming Revised5 Report (as proposed). Features that are in the Revised4 or Revised5 Report but not in the ANSI/IEEE standard are identified as such when they are described.
The first edition of this book described a number of extensions supported by the Chez Scheme implementation of Scheme. They have been removed from this edition. The primary rationale for including Chez Scheme-specific features in the first edition was that the standard language was really too small to be viable and including the extensions was necessary to show the full flavor of the language. The standard language has expanded considerably since then and now stands on its own. Features specific to Chez Scheme are described in The Chez Scheme System Manual [7].
A large number of small- to medium-sized examples are spread throughout the text, and one entire chapter is dedicated to the presentation of a set of longer examples. Many of the examples show how a predefined Scheme syntactic form or procedure might be implemented. Nearly all Scheme systems are interactive, and all of the examples can be entered directly from the keyboard into an interactive Scheme session.
This book is organized into nine chapters. Chapter 1 describes the properties and features of Scheme that make it a useful and enjoyable language to use. Chapter 1 also describes Scheme's notational conventions and the typographical conventions employed in this book.
Chapter 2 is an introduction to Scheme programming for the novice Scheme programmer that leads the reader through a series of examples, beginning with the simplest Scheme expressions and working toward progressively more difficult ones. Each section of Chapter 2 introduces a small set of related features, and at the end of each section is a set of exercises for further practice. The reader will learn the most from Chapter 2 by sitting at the keyboard and typing in the examples and trying the exercises.
Chapter 3 continues the introduction but covers more advanced features and concepts. Even readers with prior Scheme experience may wish to work through the examples and exercises found there.
Chapters 4 through 8 make up the reference portion of the text. They present each of Scheme's primitive procedures and syntactic forms in turn, grouping them into short sections of related procedures and forms. Chapter 4 describes operations for creating and changing variable bindings; Chapter 5, program control operations; Chapter 6, operations on the various object types (including lists, numbers, and strings); Chapter 7, input and output operations; and Chapter 8, syntactic extension.
Chapter 9 contains a collection of complete example programs or packages, each with a short overview, some examples of its use, the implementation with brief explanation, and a set of exercises for further work. Each of these programs demonstrates a particular set of features, and together they provide a picture of the author's style of programming in Scheme.
Following Chapter 9 are a bibliography, a detailed description of the formal syntax of Scheme programs and data, a concise summary of Scheme syntactic forms and procedures, and the index. The summary of forms and procedures is a useful first stop for programmers unsure of the structure of a syntactic form or the arguments expected by a primitive procedure. The page numbers appearing in the summary of forms and procedures and the italicized page numbers appearing in the index indicate the locations in the text where forms and procedures are defined.
Because the reference portion describes a number of aspects of the language not covered by the introductory chapters along with a number of interesting short examples, most readers will find it profitable to read through most of the material to become familiar with each feature and how it relates to other features. Chapter 6 is lengthy, however, and may be skimmed and later referenced as needed.
About the illustrations: The cover illustration and the illustrations at the front of each chapter are monohedral tilings created with the help of a Scheme program by artist Jean-Pierre Hébert. In a monohedral tiling, all tiles are congruent: they have the same size and shape but may be flipped. The base tile is called the prototile of the tiling. Many familiar and trivial monohedral tilings are known. No known algorithm exists, however, to decide whether a tile is the prototile of a monohedral tiling.
Some of the most interesting tilings are spiral shaped, and the spirals may have from one to many arms. They come from a number of known prototiles, the first one having been discovered by Voderberg in 1936. Illustrations of the curious Voderberg tile (on the cover and at the front of Chapter 3) show how two tiles can surround one or even two similar ones and how they can be assembled to generate straight lines, arcs or circles, random paths, or regular paths.
In the process of creating the illustrations, a Scheme program was used to define tiles and placement rules for these tiles, resulting in diverse monohedral spiral and non-spiral tilings of the plane. Monohedral tilings were output directly as plane geometries in Postscript to produce the illustrations appearing at the front of Chapters 1, 4, and 7. For the remaining illustrations, the tilings were warped in various ways and augmented with the help of Geomview (Geometry Center, Minneapolis), which allows for spatial manipulations, insertions, and adjustments in color, perspective, light, and material.
Acknowledgements: I would like to thank the many individuals who contributed in one way or another to the preparation of the first edition of this book, including Bruce Smith, Eugene Kohlbecker, Matthias Felleisen, Dan Friedman, Bruce Duba, Phil Dybvig, Guy Steele, Bob Hieb, Chris Haynes, Dave Plaisted, John Curry, Frank Silbermann, Pavel Curtis, John Wait, Rob Vollum, Arol Ambler, Gyula Magó, Don Stanat, George Cohn, Mr. Jerry Neff, and my parents, Roger S. Dybvig and Elizabeth H. Dybvig. I would like to thank as well those who contributed to the preparation of the second edition, including Bob Hieb, Carl Bruggeman, Dan Friedman, Sam Daniel, Oscar Waddell, Mike Ashley, John LaLonde, John Zuckerman, and John Simmons. Many others have offered minor corrections and suggestions since the first edition was published, for which I am also grateful. Fred pretty much slept through the writing of this edition, but I still appreciate his presence. Finally, I wish to thank my wife, Susan Dybvig, who suggested that I write this book in the first place and who lent her expertise and assistance to the production and publication of both editions.
R. Kent Dybvig
Bloomington, Indiana
R. Kent Dybvig The Scheme Programming Language, Second Edition © 1996. Electronically reproduced by permission of Prentice Hall, Upper Saddle River, New Jersey. http://www.scheme.com Illustrations © 1997 Jean-Pierre Hébert to order this book about this book |