Incompatibilities with R5RS
This section enumerates the incompatibilities between this report and the "Revised-5th report" [R5RS].
Note: This list is not authoritative, but is believed to be correct and complete.
Case sensitivity is now the default in symbols and character names. This means that code written under the assumption that symbols could be written
FOOorFooin some contexts andfooin other contexts can either be changed, be marked with the new#!fold-casedirective, or be included in a library using theinclude-cilibrary declaration. All standard identifiers are entirely in lower case.The
syntax-rulesconstruct now recognizes_(underscore) as a wildcard, which means it cannot be used as a syntax variable. It can still be used as a literal.The R5RS procedures
exact->inexactandinexact->exacthave been renamed to their R6RS names,inexactandexact, respectively, as these names are shorter and more correct. The former names are still available in the R5RS library.The guarantee that string comparison (with
string<?and the related predicates) is a lexicographical extension of character comparison (withchar<?and the related predicates) has been removed.Support for the
#character in numeric literals is no longer required.Support for the letters
s,f,d, andlas exponent markers is no longer required.Implementations of
string->numberare no longer permitted to return#fwhen the argument contains an explicit radix prefix, and must be compatible withreadand the syntax of numbers in programs.The procedures
transcript-onandtranscript-offhave been removed.Other language changes since R5RS
This section enumerates the additional differences between this report and the "Revised-5th report" [R5RS].
Note: This list is not authoritative, but is believed to be correct and complete.
Various minor ambiguities and unclarities in R5RS have been cleaned up.
Libraries have been added as a new program structure to improve encapsulation and sharing of code. Some existing and new identifiers have been factored out into separate libraries. Libraries can be imported into other libraries or main programs, with controlled exposure and renaming of identifiers. The contents of a library can be made conditional on the features of the implementation on which it is to be used. There is an R5RS compatibility library.
The expressions types
include,include-ci, andcond-expandhave been added to the base library; they have the same semantics as the corresponding library declarations.Exceptions can now be signaled explicitly with
raise,raise-continuableorerror, and can be handled withwith-exception-handlerand theguardsyntax. Any object can specify an error condition; the implementation-defined conditions signaled byerrorhave a predicate to detect them and accessor functions to retrieve the arguments passed toerror. Conditions signaled byreadand by file-related procedures also have predicates to detect them.New disjoint types supporting access to multiple fields can be generated with the
define-record-typeof SRFI 9 [SRFI-9]Parameter objects can be created with
make-parameter, and dynamically rebound withparameterize. The procedurescurrent-input-portandcurrent-output-portare now parameter objects, as is the newly introducedcurrent-error-port.Support for promises has been enhanced based on SRFI 45 [SRFI-45].
Bytevectors, vectors of exact integers in the range from 0 to 255 inclusive, have been added as a new disjoint type. A subset of the vector procedures is provided. Bytevectors can be converted to and from strings in accordance with the UTF-8 character encoding. Bytevectors have a datum representation and evaluate to themselves.
Vector constants evaluate to themselves.
The procedure
read-lineis provided to make line-oriented textual input simpler.The procedure
flush-output-portis provided to allow minimal control of output port buffering.Ports can now be designated as textual or binary ports, with new procedures for reading and writing binary data. The new predicates
input-port-open?andoutput-port-open?return whether a port is open or closed. The new procedureclose-portnow closes a port; if the port has both input and output sides, both are closed.String ports have been added as a way to read and write characters to and from strings, and bytevector ports to read and write bytes to and from bytevectors.
There are now I/O procedures specific to strings and bytevectors.
The
writeprocedure now generates datum labels when applied to circular objects. The new procedurewrite-simplenever generates labels;write-sharedgenerates labels for all shared and circular structure. Thedisplayprocedure must not loop on circular objects.The R6RS procedure
eof-objecthas been added. Eof-objects are now required to be a disjoint type.Syntax definitions are now allowed wherever variable definitions are.
The
syntax-rulesconstruct now allows the ellipsis symbol to be specified explicitly instead of the default..., allows template escapes with an ellipsis-prefixed list, and allows tail patterns to follow an ellipsis pattern.The
syntax-errorsyntax has been added as a way to signal immediate and more informative errors when a macro is expanded.The
letrec*binding construct has been added, and internaldefineis specified in terms of it.Support for capturing multiple values has been enhanced with
define-values,let-values, andlet*-values. Standard expression types which contain a sequence of expressions now permit passing zero or more than one value to the continuations of all non-final expressions of the sequence.The
caseconditional now supports=>syntax analogous tocondnot only in regular clauses but in theelseclause as well.To support dispatching on the number of arguments passed to a procedure,
case-lambdahas been added in its own library.The convenience conditionals
whenandunlesshave been added.The behavior of
eqv?on inexact numbers now conforms to the R6RS definition.When applied to procedures,
eq?andeqv?are permitted to return different answers.The R6RS procedures
boolean=?andsymbol=?have been added.Positive infinity, negative infinity,
NaN, and negative inexact zero have been added to the numeric tower as inexact values with the written representations+inf.0,-inf.0,+nan.0, and-0.0respectively. Support for them is not required. The representation-nan.0is synonymous with+nan.0.The
logprocedure now accepts a second argument specifying the logarithm base.The procedures
mapandfor-eachare now required to terminate on the shortest argument list.The procedures
memberandassocnow take an optional third argument specifying the equality predicate to be used.The numeric procedures
finite?,infinite?,nan?,exact-integer?,square, andexact-integer-sqrthave been added.The
-and/procedures and the character and string comparison predicates are now required to support more than two arguments.The forms
#tand#fare now supported as well as#tand#f.The procedures
make-list,list-copy,list-set!,string-map,string-for-each,string->vector,vector-append,vector-copy,vector-map,vector-for-each,vector->string,vector-copy!, andstring-copy!have been added to round out the sequence operations.Some string and vector procedures support processing of part of a string or vector using optional
startandendarguments.Some list procedures are now defined on circular lists.
Implementations may provide any subset of the full Unicode repertoire that includes ASCII, but implementations must support any such subset in a way consistent with Unicode. Various character and string procedures have been extended accordingly, and case conversion procedures added for strings. String comparison is no longer required to be consistent with character comparison, which is based solely on Unicode scalar values. The new
digit-valueprocedure has been added to obtain the numerical value of a numeric character.There are now two additional comment syntaxes:
#;to skip the next datum, and#| ... |#for nestable block comments.Data prefixed with datum labels
#<n>=can be referenced with#<n>#, allowing for reading and writing of data with shared structure.Strings and symbols now allow mnemonic and numeric escape sequences, and the list of named characters has been extended.
The procedures
file-exists?anddelete-fileare available in the(scheme file)library.An interface to the system environment, command line, and process exit status is available in the
(scheme process-context)library.Procedures for accessing time-related values are available in the
(scheme time)library.A less irregular set of integer division operators is provided with new and clearer names.
The
loadprocedure now accepts a second argument specifying the environment to load into.The
call-with-current-continuationprocedure now has the synonymcall/cc.The semantics of read-eval-print loops are now partly prescribed, requiring the redefinition of procedures, but not syntax keywords, to have retroactive effect.
The formal semantics now handles
dynamic-wind.Incompatibilities with R6RS
This section enumerates the incompatibilities between R7RS and the "Revised-6th report" [R6RS] and its accompanying Standard Libraries document.
Note: This list is not authoritative, and is possibly incomplete.
R7RS libraries begin with the keyword
define-libraryrather thanlibraryin order to make them syntactically distinguishable from R6RS libraries. In R7RS terms, the body of an R6RS library consists of a single export declaration followed by a single import declaration, followed by commands and definitions. In R7RS, commands and definitions are not permitted directly within the body: they have to be be wrapped in abeginlibrary declaration.There is no direct R6RS equivalent of the
include,include-ci,include-library-declarations, orcond-expandlibrary declarations. On the other hand, the R7RS library syntax does not support phase or version specifications.The grouping of standardized identifiers into libraries is different from the R6RS approach. In particular, procedures which are optional in R5RS, either expressly or by implication, have been removed from the base library. Only the base library itself is an absolute requirement.
No form of identifier syntax is provided.
Internal syntax definitions are allowed, but uses of a syntax form cannot appear before its definition; the
even/oddexample given in R6RS is not allowed.The R6RS exception system was incorporated as-is, but the condition types have been left unspecified. In particular, where R6RS requires a condition of a specified type to be signaled, R7RS says only "it is an error", leaving the question of signaling open.
Full Unicode support is not required. Normalization is not provided. Character comparisons are defined by Unicode, but string comparisons are implementation-dependent. Non-Unicode characters are permitted.
The full numeric tower is optional as in R5RS, but optional support for IEEE infinities,
NaN, and-0.0was adopted from R6RS. Most clarifications on numeric results were also adopted, but the R6RS proceduresreal-valued?,rational-valued?, andinteger-valued? were not. The R6RS division operatorsdiv,mod,div-and-mod,div0,mod0anddiv0-and-mod0are not provided.When a result is unspecified, it is still required to be a single value. However, non-final expressions in a body can return any number of values.
The semantics of
mapandfor-eachhave been changed to use the SRFI 1 [SRFI-1] early termination behavior. Likewise,assocandmembertake an optionalequal?argument as in SRFI 1, instead of the separateasspandmempprocedures of R6RS.The R6RS
quasiquoteclarifications have been adopted, with the exception of multiple-argumentunquoteandunquote-splicing.The R6RS method of specifying mantissa widths was not adopted.
String ports are compatible with SRFI 6 [SRFI-6] rather than R6RS.
R6RS-style bytevectors are included, but only the unsigned byte (
u8) procedures have been provided. The lexical syntax uses#u8for compatibility with SRFI 4 [SRFI-4], rather than the R6RS#vu8style.The utility macros
whenandunlessare provided, but their result is left unspecified.The remaining features of the Standard Libraries document were left to future standardization efforts.
The text herein was sourced and adapted as described in the "R7RS attribution of various text snippets" appendix.