Revised5.92Report on the Algorithmic Language Scheme

Revised5.92Report on the Algorithmic Language Scheme

. Revised5 92 Report on the Algorithmic Language Scheme MICHAEL SPERBER WILLIAM CLINGER, R. KENT DYBVIG, MATTHEW FLATT, ANTON VAN STRAATEN (Editors) RICHARD KELSEY, JONATHAN REES (Editors, Revised5 Report on the Algorithmic Language Scheme) ROBERT BRUCE FINDLER, JACOB MATTHEWS (Authors, formal semantics) 18 January 2007 SUMMARY The report gives a defining description of the programming language Scheme. Scheme is a statically scoped and properly tail-recursive dialect of the Lisp programming language invented by Guy Lewis Steele Jr. and Gerald Jay Sussman. It was designed to have an exceptionally clear and simple semantics and few different ways to form expressions. A wide variety of programming paradigms, including imperative, functional, and message passing styles, find convenient expression in Scheme. The introduction offers a brief history of the language and of the report. It also gives a short introduction to the basic concepts of the language. Chapter 2 explains Scheme’s number types. Chapter 3 defines the read syntax of Scheme programs. Chapter 4 presents the fundamental semantic ideas of the language. Chapter 5 defines notational conventions used in the rest of the report. Chapters 6 and 7 describe libraries and top-level programs, the basic organizational units of Scheme programs. Chapter 8 explains the expansion process for Scheme code. Chapter 9 explains the Scheme base library which contains the fundamental forms useful to programmers. Appendix 10 provides a formal semantics for a core of Scheme. Appendix A contains definitions for some of the derived forms described in the report. The report concludes with a list of references and an alphabetic index. This report is accompanied by a report describing standard libraries [40]; references to this document are identified by designations such as “library section” or “library chapter”. *** DRAFT*** This is a preliminary draft. It is intended to reflect the decisions taken by the editors’ committee, but contains many mistakes, ambiguities and inconsistencies. 2 Revised5.92 Scheme CONTENTS 9 Baselibrary ..................... 30 Introduction ...................... 3 9.1 Basetypes................... 30 9.2 Definitions................... 30 Description of the language 9.3 Syntax definitions . 31 1 OverviewofScheme................. 6 9.4 Bodiesandsequences. 31 1.1 Basictypes .................. 6 9.5 Expressions . 31 1.2 Expressions .................. 7 9.6 Equivalence predicates . 36 1.3 Variables and binding . 7 9.7 Procedure predicate . 39 1.4 Definitions................... 7 9.8 Unspecified value . 39 1.5 Procedures .................. 8 9.9 Generic arithmetic . 39 1.6 Procedure calls and syntactic keywords . 8 9.10Booleans.................... 46 1.7 Assignment .................. 8 9.11 Pairs and lists . 46 1.8 Derived forms and macros . 9 9.12Symbols .................... 49 1.9 Syntactic datums and datum values . 9 9.13 Characters. 49 1.10Libraries.................... 9 9.14Strings..................... 50 1.11 Top-level programs . 9 9.15Vectors .................... 51 2 Numbers....................... 10 9.16 Errors and violations . 52 2.1 Numericaltypes . 10 9.17 Controlfeatures. 52 2.2 Exactness ................... 10 9.18 Iteration.................... 54 2.3 Implementation restrictions . 10 9.19 Quasiquotation . 55 2.4 Infinities and NaNs . 11 9.20 Binding constructs for syntactic keywords . 56 3 Lexical syntax and read syntax . 11 9.21 Macro transformers . 57 3.1 Notation.................... 11 9.22 Tail calls and tail contexts . 59 3.2 Lexicalsyntax. 12 3.3 Readsyntax.................. 16 Formal Semantics 4 Semanticconcepts. 17 10 Formal semantics . 61 4.1 Programs and libraries . 17 10.1 Grammar . 61 4.2 Variables, syntactic keywords, and regions . 17 10.2Quote ..................... 64 4.3 Exceptional situations . 18 10.3 Multiple Values . 64 4.4 Argument checking . 18 10.4Exceptions .................. 64 4.5 Safety ..................... 18 10.5 Arithmetic & Basic Forms . 66 4.6 Booleanvalues ....... ....... .. 19 10.6Pairs&Eqv.................. 67 4.7 Multiple return values . 19 10.7 Procedures & Application . 68 4.8 Storagemodel. ....... ....... .. 19 10.8 Call/cc and Dynamic Wind . 71 4.9 Proper tail recursion . 19 10.9 Library Top Level . 71 5 Notation and terminology . 20 10.10Underspecification . 72 5.1 Requirement levels . 20 Appendices 5.2 Entryformat ................. 20 A Sample definitions for derived forms . 74 5.3 Evaluation examples . 21 B Additional material . 75 5.4 Unspecified behavior . 21 CExample ....................... 75 5.5 Exceptional situations . 22 References........................ 77 5.6 Naming conventions . 22 Alphabetic index of definitions of concepts, key- 5.7 Syntax violations . 22 words, and procedures . 80 6 Libraries ....................... 22 6.1 Library form . 23 6.2 Import and export levels . 25 6.3 Primitive syntax . 26 6.4 Examples ................... 27 7 Top-level programs . 28 7.1 Top-level program syntax . 28 7.2 Top-level program semantics . 28 8 Expansionprocess. 29 Introduction 3 INTRODUCTION Programming languages should be designed not by piling As Scheme became more widespread, local dialects be- feature on top of feature, but by removing the weaknesses gan to diverge until students and researchers occasion- and restrictions that make additional features appear nec- ally found it difficult to understand code written at other essary. Scheme demonstrates that a very small number of sites. Fifteen representatives of the major implementa- rules for forming expressions, with no restrictions on how tions of Scheme therefore met in October 1984 to work they are composed, suffice to form a practical and efficient toward a better and more widely accepted standard for programming language that is flexible enough to support Scheme. Participating in this workshop were Hal Abel- most of the major programming paradigms in use today. son, Norman Adams, David Bartley, Gary Brooks, William Clinger, Daniel Friedman, Robert Halstead, Chris Han- Scheme was one of the first programming languages to in- son, Christopher Haynes, Eugene Kohlbecker, Don Oxley, corporate first class procedures as in the lambda calculus, Jonathan Rees, Guillermo Rozas, Gerald Jay Sussman, and thereby proving the usefulness of static scope rules and Mitchell Wand. Kent Pitman made valuable contributions block structure in a dynamically typed language. Scheme to the agenda for the workshop but was unable to at- was the first major dialect of Lisp to distinguish proce- tend the sessions. Their report [7], edited by Will Clinger, dures from lambda expressions and symbols, to use a sin- was published at MIT and Indiana University in the sum- gle lexical environment for all variables, and to evaluate mer of 1985. Further revision took place in the spring the operator position of a procedure call in the same way of 1986 [9] (edited by Jonathan Rees and Will Clinger), as an operand position. By relying entirely on procedure and in the spring of 1988 [11] (also edited by Will Clinger calls to express iteration, Scheme emphasized the fact that and Jonathan Rees). Another revision published in 1998, tail-recursive procedure calls are essentially gotos that pass edited by Richard Kelsey, Will Clinger and Jonathan Rees, arguments. Scheme was the first widely used program- reflected further revisions agreed upon in a meeting at Xe- ming language to embrace first class escape procedures, rox PARC in June 1992 [26]. from which all previously known sequential control struc- tures can be synthesized. A subsequent version of Scheme Attendees of the Scheme Workshop in Pittsburgh in Octo- introduced the concept of exact and inexact numbers, an ber 2002 formed a Strategy Committee to discuss a process extension of Common Lisp’s generic arithmetic. More re- for producing new revisions of the report. The strategy cently, Scheme became the first programming language to committee drafted a charter for Scheme standardization. support hygienic macros, which permit the syntax of a This charter, together with a process for selecting edito- block-structured language to be extended in a consistent rial committees for producing new revisions for the report, and reliable manner. was confirmed by the attendees of the Scheme Workshop in Boston in November 2003. Subsequently, a Steering Com- Numerical computation was long neglected by the Lisp mittee according to the charter was selected, consisting of community. Until Common Lisp there was no carefully Alan Bawden, Guy L. Steele Jr., and Mitch Wand. An thought out strategy for organizing numerical computa- editors’ committee charged with producing this report was tion, and with the exception of the MacLisp system [35] also formed at the end of 2003, consisting of Will Clinger, little effort was made to execute numerical code efficiently. R. Kent Dybvig, Marc Feeley, Matthew Flatt, Richard The Scheme reports recognized the excellent work of the Kelsey, Manuel Serrano, and Mike Sperber, with Marc Fee- Common Lisp committee and accepted many of their rec- ley acting as Editor-in-Chief. Richard Kelsey resigned from ommendations, while simplifying and generalizing in some the committee in April 2005, and was replaced by Anton ways consistent with the purposes of Scheme. van Straaten. Marc Feeley and Manuel Serrano resigned from the committee in January 2006. Subsequently, the Background charter was revised to reduce the size of the editors’ com- mittee to five and to replace the office of Editor-in-Chief by The first description of Scheme was written by Gerald Jay a Chair and a Project

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    87 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us