Next: Session Support, Previous: Procedures, Up: Other Packages [Contents][Index]
Next: With-File, Previous: Standards Support, Up: Standards Support [Contents][Index]
The r2rs
, r3rs
, r4rs
, and r5rs
features
attempt to provide procedures and macros to bring a Scheme
implementation to the desired version of Scheme.
Requires features implementing procedures and optional procedures
specified by Revised^2 Report on the Algorithmic Language Scheme;
namely rev3-procedures
and rev2-procedures
.
Requires features implementing procedures and optional procedures
specified by Revised^3 Report on the Algorithmic Language Scheme;
namely rev3-procedures
.
Note: SLIB already mandates the r3rs
procedures which can
be portably implemented in r4rs
implementations.
Requires features implementing procedures and optional procedures
specified by Revised^4 Report on the Algorithmic Language Scheme;
namely rev4-optional-procedures
.
Requires features implementing procedures and optional procedures
specified by Revised^5 Report on the Algorithmic Language Scheme;
namely values
, macro
, and eval
.
Next: Transcripts, Previous: RnRS, Up: Standards Support [Contents][Index]
(require 'with-file)
Description found in R4RS.
Next: Rev2 Procedures, Previous: With-File, Up: Standards Support [Contents][Index]
(require 'transcript)
Redefines read-char
, read
, write-char
,
write
, display
, and newline
.
Next: Rev4 Optional Procedures, Previous: Transcripts, Up: Standards Support [Contents][Index]
(require 'rev2-procedures)
The procedures below were specified in the Revised^2 Report on
Scheme. N.B.: The symbols 1+
and -1+
are not
R4RS syntax. Scheme->C, for instance, chokes on this
module.
string1 and string2 must be a strings, and start1, start2 and end1 must be exact integers satisfying
0 <= start1 <= end1 <= (string-length string1) 0 <= start2 <= end1 - start1 + start2 <= (string-length string2)
substring-move-left!
and substring-move-right!
store
characters of string1 beginning with index start1
(inclusive) and ending with index end1 (exclusive) into
string2 beginning with index start2 (inclusive).
substring-move-left!
stores characters in time order of
increasing indices. substring-move-right!
stores characters in
time order of increasing indeces.
Fills the elements start–end of string with the character char.
≡ (= 0 (string-length str))
Destructively appends its arguments. Equivalent to nconc
.
Adds 1 to n.
Subtracts 1 from n.
These are equivalent to the procedures of the same name but without the trailing ‘?’.
Next: Multi-argument / and -, Previous: Rev2 Procedures, Up: Standards Support [Contents][Index]
(require 'rev4-optional-procedures)
For the specification of these optional procedures, See Standard procedures in Revised(4) Scheme.
Next: Multi-argument Apply, Previous: Rev4 Optional Procedures, Up: Standards Support [Contents][Index]
(require 'multiarg/and-)
For the specification of these optional forms, See Numerical operations in Revised(4) Scheme.
Next: Rationalize, Previous: Multi-argument / and -, Up: Standards Support [Contents][Index]
(require 'multiarg-apply)
For the specification of this optional form, See Control features in Revised(4) Scheme.
Next: Promises, Previous: Multi-argument Apply, Up: Standards Support [Contents][Index]
(require 'rationalize)
Computes the correct result for exact arguments (provided the implementation supports exact rational numbers of unlimited precision); and produces a reasonable answer for inexact arguments when inexact arithmetic is implemented using floating-point.
Rationalize
has limited use in implementations lacking exact
(non-integer) rational numbers. The following procedures return a list
of the numerator and denominator.
find-ratio
returns the list of the simplest
numerator and denominator whose quotient differs from x by no more
than e.
(find-ratio 3/97 .0001) ⇒ (3 97) (find-ratio 3/97 .001) ⇒ (1 32)
find-ratio-between
returns the list of the simplest
numerator and denominator between x and y.
(find-ratio-between 2/7 3/5) ⇒ (1 2) (find-ratio-between -3/5 -2/7) ⇒ (-1 2)
Next: Dynamic-Wind, Previous: Rationalize, Up: Standards Support [Contents][Index]
(require 'promise)
(require 'delay)
provides force
and delay
:
Change occurrences of (delay expression)
to
(make-promise (lambda () expression))
(see Control features in Revised(4) Scheme).
Next: Eval, Previous: Promises, Up: Standards Support [Contents][Index]
(require 'dynamic-wind)
This facility is a generalization of Common LISP unwind-protect
,
designed to take into account the fact that continuations produced by
call-with-current-continuation
may be reentered.
The arguments thunk1, thunk2, and thunk3 must all be procedures of no arguments (thunks).
dynamic-wind
calls thunk1, thunk2, and then
thunk3. The value returned by thunk2 is returned as the
result of dynamic-wind
. thunk3 is also called just before
control leaves the dynamic context of thunk2 by calling a
continuation created outside that context. Furthermore, thunk1 is
called before reentering the dynamic context of thunk2 by calling
a continuation created inside that context. (Control is inside the
context of thunk2 if thunk2 is on the current return stack).
Warning: There is no provision for dealing with errors or
interrupts. If an error or interrupt occurs while using
dynamic-wind
, the dynamic environment will be that in effect at
the time of the error or interrupt.
Next: Values, Previous: Dynamic-Wind, Up: Standards Support [Contents][Index]
(require 'eval)
Evaluates expression in the specified environment and returns its
value. Expression must be a valid Scheme expression represented
as data, and environment-specifier must be a value returned by one
of the three procedures described below. Implementations may extend
eval
to allow non-expression programs (definitions) as the first
argument and to allow other values as environments, with the restriction
that eval
is not allowed to create new bindings in the
environments associated with null-environment
or
scheme-report-environment
.
(eval '(* 7 3) (scheme-report-environment 5)) ⇒ 21 (let ((f (eval '(lambda (f x) (f x x)) (null-environment)))) (f + 10)) ⇒ 20
Version must be an exact non-negative integer n
corresponding to a version of one of the Revised^n Reports on
Scheme. Scheme-report-environment
returns a specifier for an
environment that contains the set of bindings specified in the
corresponding report that the implementation supports.
Null-environment
returns a specifier for an environment that
contains only the (syntactic) bindings for all the syntactic keywords
defined in the given version of the report.
Not all versions may be available in all implementations at all times. However, an implementation that conforms to version n of the Revised^n Reports on Scheme must accept version n. An error is signalled if the specified version is not available.
The effect of assigning (through the use of eval
) a variable
bound in a scheme-report-environment
(for example car
) is
unspecified. Thus the environments specified by
scheme-report-environment
may be immutable.
This optional procedure returns a specifier for the environment that contains implementation-defined bindings, typically a superset of those listed in the report. The intent is that this procedure will return the environment in which the implementation would evaluate expressions dynamically typed by the user.
Here are some more eval
examples:
(require 'eval) ⇒ #<unspecified> (define car 'volvo) ⇒ #<unspecified> car ⇒ volvo (eval 'car (interaction-environment)) ⇒ volvo (eval 'car (scheme-report-environment 5)) ⇒ #<primitive-procedure car> (eval '(eval 'car (interaction-environment)) (scheme-report-environment 5)) ⇒ volvo (eval '(eval '(set! car 'buick) (interaction-environment)) (scheme-report-environment 5)) ⇒ #<unspecified> car ⇒ buick (eval 'car (scheme-report-environment 5)) ⇒ #<primitive-procedure car> (eval '(eval 'car (interaction-environment)) (scheme-report-environment 5)) ⇒ buick
Next: SRFI, Previous: Eval, Up: Standards Support [Contents][Index]
(require 'values)
values
takes any number of arguments, and passes (returns) them
to its continuation.
thunk must be a procedure of no arguments, and proc must be
a procedure. call-with-values
calls thunk with a
continuation that, when passed some values, calls proc with those
values as arguments.
Except for continuations created by the call-with-values
procedure, all continuations take exactly one value, as now; the effect
of passing no value or more than one value to continuations that were
not created by the call-with-values
procedure is
unspecified.
Previous: Values, Up: Standards Support [Contents][Index]
(require 'srfi)
Implements Scheme Request For Implementation (SRFI) as described at http://srfi.schemers.org/
Syntax: Each <clause> should be of the form
(<feature> <expression1> …)
where <feature> is a boolean expression composed of symbols and ‘and’, ‘or’, and ‘not’ of boolean expressions. The last <clause> may be an “else clause,” which has the form
(else <expression1> <expression2> …).
The first clause whose feature expression is satisfied is expanded. If no feature expression is satisfied and there is no else clause, an error is signaled.
SLIB cond-expand
is an extension of SRFI-0,
http://srfi.schemers.org/srfi-0/srfi-0.html.
(define error slib:error)
(require 'srfi-1)
Implements the SRFI-1 list-processing library as described at http://srfi.schemers.org/srfi-1/srfi-1.html
(define (xcons d a) (cons a d))
.
Returns a list of length len. Element i is
(proc i)
for 0 <= i < len.
Returns a list of count numbers: (start, start+step, …, start+(count-1)*step).
Returns a circular list of obj1, obj2, ….
Determine if a transitive subset relation exists between the lists list1 …, using = to determine equality of list members.
These are linear-update variants. They are allowed, but not
required, to use the cons cells in their first list parameter to
construct their answer. lset-union!
is permitted to recycle
cons cells from any of its list arguments.
Next: Session Support, Previous: Procedures, Up: Other Packages [Contents][Index]