[R6RS] R6RS core/library strawman proposal
Anton van Straaten
anton at appsolutions.com
Wed Mar 22 10:45:41 EST 2006
I'm sure this is being posted too late to be read properly before our
call today. However, if you have a chance to read the 3-minute intro
below, and take a look at the syntax examples at the beginning of the
proposal proper, I can fill in the details in a few minutes on the
phone, if the agenda allows. Kent, I could use 5-10 minutes for this,
if it's not too last-minute.
R6RS core/library strawman proposal
===================================
3-minute intro
--------------
In order to provide a suitable framework for the split between core
language features and libraries, as well as to allow programmers to
specify which language features a given library depends on, this
proposal augments or replaces the <language> specification in SRFI 83
with a simple s-exp specification which allows certain language features
to be composed.
To demonstrate the composition possibilities, two "primitive" languages
have been specified: 'r6rs-primitives' and 'r6rs-pure-primitives'
These implement a language which contains the primitive expression types
defined in R5RS 4.1. The only difference between the two primitive
languages is that the 'pure' variant does not provide SET!
Whether this choice between pure & impure primitive languages is
ultimately provided is not the primary point here: the intent is to
raise the possibility of a choice between primitive languages. If such
a choice is not provided, it simply reduces the set of primitive
languages to one, i.e. 'r6rs-primitive'.
In addition to the primitive languages, the proposed language
specification mechanism allows a macro system to be specified, either
'syntax-rules' or 'syntax-case'.
By specifying the combination of a primitive language, a macro system,
and libraries, various useful "derived language" variants can be
specified. To illustrate the possibilities, this proposal specifies a
number of such variants, such as 'r6rs', 'r6rs-pure', 'r6rs-small', and
'r6rs-big'. For now, the details of these variants are less important
than the semantics of the language specification mechanism.
For syntax and examples, skip ahead past the Notes & Issues below to the
first section of the actual proposal.
Notes & Issues
--------------
* This proposal currently mostly avoids the term "core". It is intended
to provide a framework which will allow for appropriate definitions of
terms such as "core", and for addressing the organizational requirements
of the R6RS document.
* Features defined as "primitive" may not correspond exactly to the
actual primitive features in any given implementation. However, a
similar situation existed for the R5RS. The term "primitive" is not
intended to mandate any implementation characteristics, other than the
specified organization of libraries. In this proposal, "primitive"
essentially describes features which cannot reasonably be obtained by
importing from a SRFI 83 library, without requiring some magical
semantics for library imports.
* The <macro-system> clause in the syntax of the <language> form could
be replaced by a more general <language-slice>* clause, which would
support composition of modular sets of primitive language features,
other than macro systems. This could make sense if there were a larger
set of primitive features that needed to be combined compositionally.
* The two primitive languages, 'r6rs-pure-primitives' and
'r6rs-primitives' differ only in that the latter includes SET! Assuming
this ability to specify a pure language is adopted, there may be more
concise ways to achieve it than by providing two separate primitive
languages.
* The ability to specify a pure language may be more of a benefit to
programmers and to certain tools, than to compilers which can, of
course, detect the use of SET! Specifying only a single primitive
language which includes SET! could simplify the proposal slightly.
* The proposal vaguely specifies a catch-all library named 'standard'.
This is the rug under which many details have been swept. This will be
fleshed out once some agreement on the basic framework is obtained. The
more specific libraries are currently mostly based on the list provided
by Will, of functionality which a library should be able to exclude from
the language it uses.
* How much should this proposal actually require of implementations? At
a minimum, an implementation should be required to support a set of
predefined languages such as 'r6rs' and 'r6rs-big'. Beyond this, the
ability to support specification of other languages could be optional in
certain respects. Such cases have been flagged in the proposal.
Proposal
========
The library proposal, SRFI 83, specifies a single language in which
libraries can be written, "scheme://r6rs". This core/library proposal
breaks the "scheme://r6rs" language down into smaller components,
proposes additional languages composed from those components, and
provides a means of specifying libraries which depend on a composition
of language components.
In order to support composition of language features, this proposal
defines two "primitive" languages ('r6rs-primitives' and
'r6rs-pure-primitives') as well as two macro systems ('syntax-rules' and
'syntax-case'). The remaining R6RS language functionality is divided
into libraries. These components can be composed to achieve a variety
of languages with different feature sets.
SRFI 83 defines the following syntax for the LIBRARY form:
(library <lib-path> <language>
<body>)
SRFI 83 only specifies a single possible <language> form, namely
"scheme://r6rs". This proposal adds the following syntax for the
<language> form:
<language> = (scheme <derived-language>)
| (scheme <primitive-language>)
| (scheme <primitive-language> <macro-system>)
; NOTE: the latter two variants could be optional
<primitive-language> = r6rs-primitives | r6rs-pure-primitives
<derived-language> = r6rs-pure | r6rs-small | r6rs | r6rs-big
<macro-system> = syntax-rules | syntax-case
A typical library definition therefore looks like this:
(library "hello" (scheme r6rs)
...)
or:
(library "hello" (scheme r6rs-small)
(import "iteration-syntax" ; import DO and named LET
"multiple-values")
...)
A lower-level definition (if supported by an implementation) looks like
this:
(library "hello" (scheme r6rs-pure-primitives syntax-case)
(import "multiple-values")
...)
The various language identifiers, macro system identifiers, and
libraries are described below.
Primitive languages
===================
Primitive language: r6rs-pure-primitives
----------------------------------------
This language includes all of the "primitive expression types" described
in R5RS 4.1, with the exception of SET! The expression types in
question are as follows:
Variable references: <variable>
Literal expressions: (quote <datum>)
'<datum>
constant
Application: (<rator> <rand> ...)
Procedures: (lambda <formals> <body>)
Conditionals: (if t a b)
(if t a)
In addition, this language includes support for definitions as described
in R5RS 5.2, i.e. 'define'
The quasiquote reader shortcuts (` , ,@) will exist in this language,
but the identifiers quasiquote, unquote, and unquote-splicing will be
unbound.
Primitive language: r6rs-primitives
-----------------------------------
This language is a superset of the r6rs-pure-primitives language, with a
single addition: support for the assignment syntax, SET!
Macro systems
=============
Macro system: syntax-rules
--------------------------
Provides define-syntax, let-syntax, letrec-syntax, and the syntax-rules
macro system.
Macro system: syntax-case
-------------------------
Provides define-syntax, let-syntax, letrec-syntax, the syntax-case macro
system, and syntax-rules.
Libraries
=========
The following libraries must be provided as part of an R6RS
implementation, as libraries importable via the SRFI 83 IMPORT form.
Library: core-syntax
--------------------
The core-syntax library contains derived expression types which most
Scheme programs are expected to use.
R5RS 4.2.1 Conditionals: cond, case, and, or
R5RS 4.2.2 Binding constructs: let, let*, letrec
R5RS 4.2.6 Quasiquotation: quasiquote, unquote, unquote-splicing
R5RS 4.2.3 Sequencing: begin
Library: standard
-----------------
This library is currently a catch-all intended to include all
essentially non-controversial R6RS procedures. More controversial
procedures and derived syntax are defined in the libraries below. If
the 'standard' library exists in a future versions of this proposal, it
is likely to be composed of a number of other libraries. For the
current purposes, this library includes and provides the functionality
of the core-syntax library above.
Library: iteration-syntax
-------------------------
R5RS 4.2.4: do, named let
Library: promises
-----------------
R5RS 4.2.5: delay
R5RS 6.4: force
Library: pair-mutation
----------------------
R5RS 6.3.2: set-car! set-cdr!
Library: multiple-values
------------------------
values, call-with-values, let-values, etc.
Library: eval
-------------
load, eval, scheme-report-environment, null-environment
Library: fixnum
---------------
fx+ etc.
Library: flonum
---------------
fl+ etc.
Library: hash-tables
--------------------
Hash tables, hash functions (latter possibly separate library).
Derived languages
=================
R6RS will specify one or more derived languages, including the 'r6rs'
language. The languages listed below are examples of the kind of
derived languages which might be specified.
The derived languages are so named because they are equivalent to a
language obtained from a combination of a primitive language and a set
of libraries. For example, a library which uses the derived language
'r6rs-pure' would be written as follows:
(library "hello" (scheme r6rs-pure)
...)
This same library could be implemented in terms of the
r6rs-pure-primitives language as follows:
(library "hello" (scheme r6rs-pure-primitives syntax-rules)
(import "standard")
...)
In the languages defined below, the above equivalence is presented as
follows:
(scheme r6rs-pure)
=>
(scheme r6rs-pure-primitives syntax-rules)
(import standard)
Derived language: r6rs-pure
---------------------------
As defined above. This language provides only non-mutating Scheme
operations and hygienic-only macros (syntax-rules).
Derived language: r6rs-small
----------------------------
This is a fairly complete R6RS language which excludes certain less
essential or controversial features such as DO, named LET, fixnum and
flonum operations (fx* and fl*), SET-CAR!, SET-CDR!, and multiple value
handling forms. Its definition is as follows:
(scheme r6rs-small)
=>
(scheme r6rs-primitives syntax-case)
(import standard)
Derived language: r6rs
----------------------
This is a complete R6RS language which only excludes certain libraries
not considered part of the base R6RS language, e.g. promises, hash
tables, records, and 'eval'.
(scheme r6rs)
=>
(scheme r6rs-small)
(import iteration-syntax fixnums flonums pair-mutation multiple-values)
=>
(scheme r6rs-primitives syntax-case)
(import standard iteration-syntax fixnums flonums pair-mutation
multiple-values)
Derived language: r6rs-big
--------------------------
This is a complete R6RS language which includes all features defined in
the R6RS.
(scheme r6rs-big)
=>
(scheme r6rs)
(import promises eval records hash-tables)
=>
(scheme r6rs-primitives syntax-case)
(import standard iteration-syntax promises fixnums flonums
pair-mutation multiple-values eval records hash-tables)
Derived language: r5rs
----------------------
This is a compatibility language which provides only those features
found in R5RS.
(scheme r5rs)
=>
(scheme r6rs-primitives syntax-rules)
(import r5rs-standard)
The above assumes that the 'r6rs-primitives' language is compatible with
r5rs. The 'r5rs-standard' library may be composed of certain compatible
r6rs libraries - details to follow.
*END*
More information about the R6RS
mailing list