This is a proposal for standard modules in R7RS small Scheme. I am publishing this document to invite wide comment. There is nothing official about it. I acknowledge the kind help of members of the r6rs-discuss mailing list and the #scheme IRC channel in the discussions that led up to this document. However, I retain sole responsibility for it, including all errors.
Part 6 was originally my proposal for feature groups, but I have now been convinced that modules can do the same job, given the special behavior of the %scheme module explained below. Note that the % signs are typographical, not part of the module names. I use them here in preference to HTML mail or some such. Introduction The charter for small Scheme requires only that the features of IEEE Scheme must be provided by small Scheme, and even then they may be removed "if a strong case can be made that they are fundamentally flawed". IEEE Scheme is the smallest of the four currently used Scheme standards: IEEE < R4RS < R5RS < R6RS (with a few exceptions). In addition, there is a great deal of non-obvious optionality specified in R5RS. For example, there are several procedures that need not be provided if the implementation only supports real numbers. What follows is a first cut at factoring R5RS plus my proposal for additional features into 14 standard modules. For a complete list of my proposed features and their modules, including their presence in various standards, see the spreadsheet linked from http://tinyurl.com/thing-one . The column "Report order" represents the order of elements in the R5RS, with my proposed additions inserted in roughly appropriate places. The standard modules The %scheme standard module exports 183 core features, which are not enumerated here. When a REPL starts, this module is normally already imported. This module also exports the identifiers of any of the standard modules that are built in to the Scheme implementation. Thus, importing a standard module may: * do nothing, if the module is already imported or is built-in * signal an error, if the module is unavailable in the implementation * mutate the implementation to support the module as well as importing its names There is nothing to prevent an implementation that does not provide a standard module from exporting one of its identifiers in this module, provided it does so in way consistent with its standard binding. The %inexact module provides inexact rational numbers, typically bounded in both magnitude and precision, and exports the 10 identifiers exp, log, sin, cos, tan, asin, acos, atan, sqrt from IEEE Scheme. The %complex module provides non-real complex numbers, and exports the 6 identifiers angle, imag-part, magnitude, make-polar, make-rectangular, real-part from IEEE Scheme. The %delay module exports the 4 identifiers delay, lazy, force, eager. None of these are in IEEE Scheme. The %eval module exports the 3 identifiers eval, null-environment, scheme-report-environment. None of these are in IEEE Scheme. The %repl module implies the presence of a REPL, and exports the 1 identifier interaction-environment, which is not in IEEE Scheme. It cannot be available if the %eval module is not. The %multiple-values module provides multiple value returns, and exports the 5 identifiers call-with-values, let-values, let*-values, receive, values. None of these are in IEEE Scheme. The %files module provides access to an external file system, and exports the 8 identifiers call-with-input-file, call-with-output-file, delete-file, file-exists?, open-input-file, open-output-file, with-input-from-file (not in IEEE Scheme, optional in R5RS), with-output-to-file (ditto). The 2 identifiers open-u8-input-file and open-u8-output-file are also exported if the %binary module is imported. The %reader module exports the 2 identifiers read, case-folding. The latter is not in IEEE Scheme or R5RS). The %writer module exports the 2 identifiers display, write from IEEE Scheme. The %binary module provides simple byte-level I/O, and exports the 9 identifiers close-u8-sink, close-u8-source, peek-u8, port-u8-position, read-u8, set-port-u8-position!, u8-sink, u8-source, write-u8. None of these are in IEEE Scheme or R5RS. This feature can be available even if the %files module is not; for example, for network I/O. Note that if both this module and %files are imported, then open-u8-input-file and open-u8-output-file are also exported. The %context module provides access to the context from which Scheme was invoked, and exports the 4 identifiers environment-variable, environment-variables, command-line, quit. None of these are in IEEE Scheme or R5RS. The %load module provides access to loading files of Scheme code (which may be source code or in some compiled format). It exports the 1 identifier load, which is not in IEEE Scheme and is optional in R5RS. This feature cannot be available if the %eval module is not. Most likely the %files feature should be available too, though in principle load's argument could be something else. The %transcripts module exports the 2 identifiers transcript-on, transcript-off. Neither of these is in IEEE Scheme, and they are optional in R5RS. Removed features As part of this proposal, I am proposing the removal of 3 R5RS procedures from small Scheme. The char-ready? procedure is not in IEEE Scheme and doesn't, in general, do what users will expect. The reasons for removing the string-set! and string-fill! procedures are explained separately. I note here only that string-set! is in IEEE Scheme, but string-fill! is not. -- The experiences of the past show John Cowan that there has always been a discrepancy [email protected] between plans and performance. http://www.ccil.org/~cowan --Emperor Hirohito, August 1945 _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
