Draft ANSI Smalltalk Standard
Total Page:16
File Type:pdf, Size:1020Kb
NCITS J20 DRAFT December, 1997 of ANSI Smalltalk Standard revision 1.9 Draft American National Standard for Information Systems - Programming Languages - Smalltalk Notice This is a draft proposed American National Standard. As such, this is not a completed standard. The Technical Committee may modify this document as a result of comments received during public review and its approval as a standard. Permission is granted to members of NCITS, its technical committees, and their associated task groups to reproduce this document for the purposes of NCITS standardization activities without further permission, provided this notice is included. All other rights are reserved. Any commercial or for-profit reproduction is strictly prohibited. NCITS J20 DRAFT December, 1997 ii of ANSI Smalltalk Standard revision 1.9 Copyright Copyright 1997 National Committee for Information Technology Standards Permission is granted to duplicate this document for the purpose of reviewing the draft standard. NCITS J20 DRAFT December, 1997 iii of ANSI Smalltalk Standard revision 1.9 Table of Contents Page FORWARD vi 1. GOALS AND SCOPE .................................................................................................................... 5 2. CONFORMING IMPLEMENTATIONS AND PROGRAMS .................................................. 7 3. THE SMALLTALK LANGUAGE ............................................................................................... 8 3.1 COMPUTATIONAL MODEL OF SMALLTALK EXECUTION................................................................. 9 3.2 THE SYNTAX OF SMALLTALK PROGRAMS ................................................................................... 10 3.3 SMALLTALK ABSTRACT PROGRAM GRAMMAR ........................................................................... 11 3.4 METHOD GRAMMAR.................................................................................................................... 18 3.5 LEXICAL GRAMMAR .................................................................................................................... 31 3.6 IMPLEMENTATION LIMITS............................................................................................................ 35 4. SMALLTALK INTERCHANGE FORMAT............................................................................. 35 4.1 INTERCHANGE FORMAT BNF SYNTAX ........................................................................................ 36 5. STANDARD CLASS LIBRARY................................................................................................. 40 5.1 DEFINITIONS AND CONCEPTS....................................................................................................... 40 5.2 STANDARD GLOBALS .................................................................................................................. 49 5.3 FUNDAMENTAL PROTOCOLS........................................................................................................ 51 5.4 VALUABLE PROTOCOLS............................................................................................................... 79 5.5 EXCEPTION PROTOCOLS .............................................................................................................. 88 5.6 NUMERIC PROTOCOLS ............................................................................................................... 114 5.7 COLLECTION PROTOCOLS .......................................................................................................... 156 5.8 DATE AND TIME PROTOCOLS..................................................................................................... 249 5.9 STREAM PROTOCOLS ................................................................................................................. 273 5.10 FILE STREAM PROTOCOLS ......................................................................................................... 288 6. GLOSSARY................................................................................................................................ 296 7. INDEX OF PROTOCOLS......................................................................................................... 302 8. REFERENCES ........................................................................................................................... 304 NCITS J20 DRAFT December, 1997 iv of ANSI Smalltalk Standard revision 1.9 Forward Smalltalk is designed to be a "single paradigm language with very simple semantics and syntax for specifying elements of a system and for describing system dynamics." The principle is explained by the designers of the original Smalltalk-80 language. There is a continuing growth of interest in the language. Its use has spread beyond the education and research community to the commercial applications in recent years. Data from many sources (including polls in conferences and reports from independent consultants) indicate the growing popularity of Smalltalk as an object-oriented programming language. There are currently at least five vendors of Smalltalk implementations. Although the actual number of Smalltalk users is unknown, we believe it to be high. (It has been estimated that Digitalk Inc., alone, had sold over 100,000 Smalltalk/V licenses by 1993.) The growth, spread and potential of Smalltalk led to a need for a standard that will protect the users' interest in compatibility and portability. The J20 technical committee was formed in the summer of 1993 to develop the ANSI Smalltalk standard. Many people and organizations in and outside of the committee have contributed to the document. The following is the list of the formal committee members. Yen-Ping Shan, Chairman Glenn Krasner, Vice-Chairman Bruce Schuchardt, Project Editor Rick DeNatale, Secretary Organization Represented Name of Representative Andersen Consulting.................................................................................. Philippe Monnet The Gallery Group, Inc............................................................................... Tony Click GemStone Systems, Inc. ........................................................................... Bruce Schuchardt Patrick Logan IBM ............................................................................................................ Yen-Ping Shan Rick DeNatale Brian Barry David G. Thomson Intuitive Systems, Ltd................................................................................. Blair McGlashan McKesson Corp. ........................................................................................ Douglas Surber ParcPlace-Digitalk...................................................................................... Glenn Krasner Quasar Knowledge Systems, Inc............................................................... David Simmons Andrew Demkin Texas Instruments, Inc............................................................................... Andy Hoffman Mary Fontana In addition, the following individuals have made significant contributions to the development of this standard: Allen Wirfs-Brock Juanita Ewing David N. Smith Pat Caudill Brian Wilkerson Fred Chan Aaron Underwood Mike Kahl Thom Boyer Bruce Conrad Daniel Lanovaz Jim Fulton Ken Huff NCITS J20 DRAFT December, 1997 5 of ANSI Smalltalk Standard revision 1.9 1. Goals and Scope The goal of the J20 Committee was to produce a written standard for the Smalltalk language such that: 1. working only from the standard, a conforming implementation can be produced, 2. Smalltalk programs which conform to the standard will have the same execution semantics on any conforming implementation, and 3. the standard shall be sufficiently complete to allow useful Smalltalk programs to be constructed. The standard does not specify the full range of class libraries one would expect to find in a Smalltalk implementation. For example, it specifies neither user-interface nor database frameworks. It does provide facilities to create such classes that will work on compliant implementations having identical external facilities to support them. Subject to the preceding points, the standard should: 1. constrain the nature of current and future implementations as little as possible, and 2. minimize impact on legacy code and implementations. Although it was not the intent of the committee to produce a conformance tool or conformance test suite, the ability to define such conformance measures should be considered as a test of whether the standard is adequately unambiguous. The following chapters specify the Smalltalk language in a way that is consistent with these goals. Chapter 2 specifies the terminology of conformance used in the standard. Chapter 3 specifies the language syntax and semantics. Chapter 4 specifies a standard interchange format for Smalltalk programs. Chapter 5 specifies the standard class library. Chapter 6 is a glossary of terms used in the document. This is followed by an index of the protocols found in Chapter 5 and a list of references that, while not part of the standard, are referred to in the text of the standard. Most current Smalltalk implementations provide syntax and semantics only for Smalltalk methods. In particular, they do not provide an explicit definition of program construction, for example class creation and global creation and initialization. These program constructs, rather, are provided via some combination of programming tools and imperative operations, i.e. the evaluation of expressions in the language. The Committee decided