John Cowan wrote:
> David Van Horn scripsit: 
>> Rather than adding this and that new binding, I think it would be more
>> fruitful to work on a "small" library system.  All of these bindings
>> could then just be imported when needed.  The document shrinks
>> dramatically in size and complexity.
> 
> This is the heart of the matter.
> 
> The questions "Should this identifier be in a module?" and "Should this
> identifier name a required feature of the standard?" are entirely
> orthogonal, yet often conflated.  R6RS has a whopping 665 bound
> identifiers, almost all of which are in libraries.  But since a conformant
> R6RS system must provide all of those libraries, little or no additional
> implementor flexibility is granted thereby, and users must go to the
> trouble of specifying the libraries they use (though there is a handy
> compound library that joins almost all of them).  I say "little or no"
> because a smart R6RS compiler might be able to use a different runtime
> if it knows that, say, mutable pairs are not in use.
> 
> Dismissing for the moment the matter of whether identifiers are in
> libraries, then, we must confront the question: "Why make a particular
> identifier a required part of the standard?"  Sometimes the answer
> is "Because it's primitive, and we can build useful things on it."
> Sometimes the answer is "Ancient tradition."  But the most satisfying
> answer, to my mind, is "Because that's what a Scheme programmer expects
> to find when they move to a new implementation."

Agreed.

As an exercise in trying to figure out precisely what one can expect to 
find when moving between Schemes, I reviewed the R3,4,5,6RS and 
IEEE/ANSI standards.  I wanted to find their least common denominator 
(the "essential" Scheme); a list of must-haves for a Scheme to be a Scheme.

Here is what I came up with, maybe it's useful:

Essential Scheme is the minimal subset of the language expected to be
supported by any Scheme system.  It represents the fundamental and
simple core of the language.  It is lightweight at the semantic and
implementation level.  It is useful for research, prototyping,
language experimentation, and understanding existing teaching
materials.  Its specification is comparable in size to research paper
accounts of Scheme (i.e. much smaller than even R3RS).

; Core
<variable>
(quote <datum>)
'<datum>
<constant>
(<operator> <operand1> ...)
(lambda <formals> <body>)
        [includes dot patterns, body is sequence of one or more expressions.]
(if <test> <consequent> <alternate>)
(set! <variable> <expression>)

; Derived
(cond <clause1> <clause2> ...)
(let <bindings> <body>)
(letrec <bindings> <body>)
(begin <expression1> <expression2> ...)

; Programs
(define <variable> <expression>) ...

; Procedures

; Booleans
(not obj)
(boolean? obj)

; Equivalence predicates
(eqv? obj1 obj2)
(eq? obj1 obj2)
(equal? obj1 obj2)

; Pairs and lists
(pair? obj)
(cons obj1 obj2)
(car pair)
(cdr pair) ; and caar...cddddr
(null? obj
(list obj ...)
(length list)
(append list1 list2)

; Symbols
(symbol? obj)
(symbol->string symbol)
(string->symbol string)

; Numbers
(number? obj)     ;; Full tower is optional
(complex? obj)
(real? obj)
(rational? obj)
(integer? obj)
(zero? z)
(positive? x)
(negative? x)
(odd? n)
(even? n)
(exact? z)
(inexact? z)
(= z1 z2)
(< x1 x2)
(> x1 x2)
(<= x1 x2)
(>= x1 x2)
(max x1 x2)
(min x1 x2)
(+ z1 z2)
(* z1 z2)
(- z1 z2)
(/ z1 z2)
(abs z)
(quotient n1 n2)
(remainder n1 n2)

; Characters
(char? obj)
(char=? char1 char2)
(char<? char1 char2)
(char>? char1 char2)
(char<=? char1 char2)
(char>=? char1 char2)
(char->integer char)
(integer->char n)

; Strings
(string? obj)
(string-length string)
(string-ref string k)
(string=? string1 string2)
(string<? string1 string2)
(string>? string1 string2)
(string<=? string1 string2)
(string>=? string1 string2)
(substring string start end)
(string-append string1 string2)
(string->list string)
(list->string chars)

; Vectors
(vector? obj)
(make-vector k)
(vector obj ...)
(vector-length vector)
(vector-ref vector k)
(vector-set! vector k obj)
(vector->list vector)
(list->vector list)

; Control features
(procedure? obj)
(apply proc args)
(map proc list)
(for-each proc list)
(call-with-current-continuation proc)

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to