Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (04/15/90)
Submitted-by: rusty@fe2o3.UUCP (Rusty Haddock)
Posting-number: Volume 90, Issue 145
Archive-name: applications/xscheme-0.20/part07
#!/bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 7 (of 7)."
# Contents: xscheme.doc
# Wrapped by tadguy@xanth on Sat Apr 14 17:07:32 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xscheme.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xscheme.doc'\"
else
echo shar: Extracting \"'xscheme.doc'\" \(52550 characters\)
sed "s/^X//" >'xscheme.doc' <<'END_OF_FILE'
X
X
X
X
X
X
X XSCHEME: An Object-oriented Scheme
X
X Version 0.17
X
X March 2, 1989
X
X
X by
X David Michael Betz
X P.O. Box 144
X Peterborough, NH 03458
X
X (603) 924-4145 (home)
X
X Copyright (c) 1989, by David Michael Betz
X All Rights Reserved
X Permission is granted for unrestricted non-commercial use
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME TABLE OF CONTENTS Page 2
X
X
X TABLE OF CONTENTS
X
X TABLE OF CONTENTS..................................2
X INTRODUCTION.......................................3
X A NOTE FROM THE AUTHOR.............................4
X EXPRESSIONS........................................5
X BINDING FORMS.....................................10
X SEQUENCING........................................11
X DELAYED EVALUATION................................12
X ITERATION.........................................13
X DEFINITIONS.......................................14
X LIST FUNCTIONS....................................15
X DESTRUCTIVE LIST FUNCTIONS........................17
X SYMBOL FUNCTIONS..................................18
X VECTOR FUNCTIONS..................................19
X ARRAY FUNCTIONS...................................20
X CONVERSION FUNCTIONS..............................21
X TYPE PREDICATES...................................22
X EQUALITY PREDICATES...............................25
X ARITHMETIC FUNCTIONS..............................26
X NUMERIC COMPARISON FUNCTIONS......................29
X BITWISE LOGICAL FUNCTIONS.........................30
X STRING FUNCTIONS..................................31
X STRING COMPARISON FUNCTIONS.......................32
X CHARACTER COMPARISON FUNCTIONS....................33
X INPUT/OUTPUT FUNCTIONS............................34
X OUTPUT CONTROL FUNCTIONS..........................36
X FILE I/O FUNCTIONS................................37
X CONTROL FEATURES..................................39
X ENVIRONMENT FUNCTIONS.............................40
X UTILITY FUNCTIONS.................................41
X SYSTEM FUNCTIONS..................................42
X OBJECT REPRESENTATIONS............................43
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME INTRODUCTION Page 3
X
X
X XScheme is an implementation of the Scheme programming language
X with extensions to support object-oriented programming.
X
X There are currently implementations of XScheme running on the
X IBM-PC and clones under MS-DOS, on the Macintosh, the Atari-ST
X and the Amiga. It is completely written in the programming
X language 'C' and is easily extended with user written built-in
X functions and classes. It is available in source form to non-
X commercial users.
X
X This document is a brief description of XScheme. XScheme
X follows the "Revised^3 Report on the Algorithmic Language
X Scheme". It assumes some knowledge of Scheme or LISP and some
X understanding of the concepts of object-oriented programming.
X
X I recommend the book "Structure and Interpretation of Computer
X Programs" by Harold Abelson and Gerald Jay Sussman and published
X by The MIT Press and the McGraw-Hill Book Company for learning
X Scheme (and programming in general). You might also find "The
X Scheme Programming Language" by R. Kent Dybvig and "The Little
X Lisper" by Daniel P. Friedman and Matthias Felleisen to be
X helpful.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME A NOTE FROM THE AUTHOR Page 4
X
X
X A NOTE FROM THE AUTHOR
X
X If you have any problems with XScheme, feel free to contact me
X for help or advice. Please remember that since XScheme is
X available in source form in a high level language, many users
X have been making versions available on a variety of machines.
X If you call to report a problem with a specific version, I may
X not be able to help you if that version runs on a machine to
X which I don't have access. Please have the version number of
X the version that you are running readily accessible before
X calling me.
X
X If you find a bug in XScheme, first try to fix the bug yourself
X using the source code provided. If you are successful in fixing
X the bug, send the bug report along with the fix to me. If you
X don't have access to a C compiler or are unable to fix a bug,
X please send the bug report to me and I'll try to fix it.
X
X Any suggestions for improvements will be welcomed. Feel free to
X extend the language in whatever way suits your needs. However,
X PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME
X FIRST!! I would like to be the clearing house for new features
X added to XScheme. If you want to add features for your own
X personal use, go ahead. But, if you want to distribute your
X enhanced version, contact me first.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME EXPRESSIONS Page 5
X
X
X EXPRESSIONS
X
X <variable>
X
X An expression consisting of a variable is a variable
X reference. The value of the variable reference is the value
X stored in the location to which the variable is bound. It
X is an error to reference an unbound variable.
X
X (QUOTE <datum>)
X '<datum>
X
X (quote <datum>) evaluates to <datum>. <Datum> may be any
X external representation of a Scheme object. This notation
X is used to include literal constants in Scheme code. (quote
X <datum>) may be abbreviated as '<datum>. The two notations
X are equivalent in all respects.
X
X <constant>
X
X Numeric constants, string constants, character constants,
X and boolean constants evaluate "to themselves"; they need
X not be quoted.
X
X (<operator> <operand>...)
X
X A procedure call is written by simply enclosing in
X parentheses expressions for the procedure to be called and
X the arguments to be passed to it. The operator and operand
X expressions are evaluated and the resulting procedure is
X passed the resulting arguments.
X
X (<object> <selector> <operand>...)
X
X A message sending form is written by enclosing in
X parentheses expressions for the receiving object, the
X message selector, and the arguments to be passed to the
X method. The receiver, selector, and argument expressions
X are evaluated, the message selector is used to select an
X appropriate method to handle the message, and the resulting
X method is passed the resulting arguments.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME EXPRESSIONS Page 6
X
X
X (LAMBDA <formals> <body>)
X
X <Formals> should be a formal argument list as described
X below, and <body> should be a sequence of one or more
X expressions. A lambda expression evaluates to a procedure.
X The environment in effect when the lambda expression is
X evaluated is remembered as part of the procedure. When the
X procedure is later called with some actual arguments, the
X environment in which the lambda expression was evaluated
X will be extended by binding the variables in the formal
X argument list to fresh locations, the corresponding actual
X argument values will be stored in those locations, and the
X expressions in the body of the lambda expression will be
X evaluated sequentially in the extended environment. The
X result of the last expression in the body will be returned
X as the result of the procedure call.
X
X <Formals> should have the following form:
X
X (<var>... [#!OPTIONAL <ovar>...] [. <rvar>])
X or
X (<var>... [#!OPTIONAL <ovar>...] [#!REST <rvar>])
X
X where:
X
X <var> is a required argument
X <ovar> is an optional argument
X <rvar> is a "rest" argument
X
X There are three parts to a <formals> list. The first lists
X the required arguments of the procedure. All calls to the
X procedure must supply values for each of the required
X arguments. The second part lists the optional arguments of
X the procedure. An optional argument may be supplied in a
X call or omitted. If it is omitted, a special value is given
X to the argument that satisfies the default-object?
X predicate. This provides a way to test to see if an
X optional argument was provided in a call or omitted. The
X last part of the <formals> list gives the "rest" argument.
X This argument will be bound to the rest of the list of
X arguments supplied to a call after the required and optional
X arguments have been removed.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME EXPRESSIONS Page 7
X
X
X (IF <test> <consequent> [<alternate>])
X
X An if expression is evaluated as follows: first, <test> is
X evaluated. If it yields a true value, then <consequent> is
X evaluated and its value is returned. Otherwise, <alternate>
X is evaluated and its value is returned. If <test> yields a
X false value and no <alternate> is specified, then the result
X of the expression is unspecified.
X
X (ACCESS <variable> <env>)
X
X <Env> is evaluated producing an environment. The result is
X the value of <variable> in this environment.
X
X (SET! <variable> <expression>)
X
X <Expression> is evaluated, and the resulting value is stored
X in the location to which <variable> is bound. <Variable>
X must be bound in some region or at the top level. The result
X of the set! expression is unspecified.
X
X (SET! (ACCESS <variable> <env>) <value>)
X
X <Env> is evaluated producing an environment. <Value> is
X evaluated and the resulting value is stored as the value of
X <variable> in this environment. The result of the set!
X expression is unspecified.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME EXPRESSIONS Page 8
X
X
X (COND <clause>...)
X
X Each clause should be of the form
X
X (<test> <expression>...)
X
X where <test> is any expression. The last <clause> may be an
X "else clause," which has the form
X
X (ELSE <expression>...)
X
X A cond expression is evaluated by evaluating the <test>
X expressions of successive <clause>s in order until one of
X them evaluates to a true value. When a <test> evaluates to
X a true value, then the remaining <expression>s in its
X <clause> are evaluated in order, and the result of the last
X <expression> in the <clause> is returned as the result of
X the entire cond expression. If the selected <clause>
X contains only the <test> and no <expression>s, then the
X value of the <test> is returned as the result. If all
X <test>s evaluate to false values, and there is no else
X clause, then the result of the conditional expression is
X unspecified; if there is an else clause, then its
X <expression>s are evaluated, and the value of the last one
X is returned.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME EXPRESSIONS Page 9
X
X
X (AND <test>...)
X
X The <test> expressions are evaluated from left to right, and
X the value of the first expression that evaluates to a false
X value is returned. Any remaining expressions are not
X evaluated. If all the expressions evaluate to true values,
X the value of the last expression is returned. If there are
X no expressions then #t is returned.
X
X (OR <test>...)
X
X The <test> expressions are evaluated from left to right, and
X the value of the first expression that evaluates to a true
X value is returned. Any remaining expressions are not
X evaluated. If all expressions evaluate to false values, the
X value of the last expression is returned. If there are no
X expressions then #f is returned.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME BINDING FORMS Page 10
X
X
X BINDING FORMS
X
X (LET [<name>] <bindings> <body>)
X
X <Bindings> should have the form
X
X ((<variable> <init>)...)
X
X where each <init> is an expression, and <body> should be a
X sequence of one or more expressions. The <init>s are
X evaluated in the current envirnoment, the <variable>s are
X bound to fresh locations holding the results, the <body> is
X evaluated in the extended environment, and the value of the
X last expression of <body> is returned. Each binding of a
X <variable> has <body> as its region.
X
X If a name is supplied, a procedure that takes the bound
X variables as its arguments and has the body of the LET as
X its body is bound to that name.
X
X (LET* <bindings> <body>)
X
X Same as LET except that the bindings are done sequentially
X from left to right and the bindings to the left are visible
X while evaluating the initialization expressions for each
X variable.
X
X (LETREC <bindings> <body>)
X
X <Bindings> should have the form
X
X ((<variable> <init>)...)
X
X and <body> should be a sequence of one or more expressions.
X The <variable>s are bound to fresh locations holding
X undefined values; the <init>s are evaluated in the resulting
X environment; each <variable> is assigned to the result of
X the corresponding <init>; the <body> is evaluated in the
X resulting environment; and the value of the last expression
X in <body> is returned. Each binding of a <variable> has the
X entire letrec expression as its region, making it possible
X to define mutually recursive procedures. One restriction of
X letrec is very important: it must be possible to evaluate
X each <init> without referring to the value of any
X <variable>. If this restriction is violated, then the
X effect is undefined, and an error may be signalled during
X evaluation of the <init>s. The restriction is necessary
X because Scheme passes arguments by value rather than by
X name. In the most common uses of letrec, all the <init>s
X are lambda expressions and the restriction is satisfied
X automatically.
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME SEQUENCING Page 11
X
X
X SEQUENCING
X
X (BEGIN <expression>...)
X (SEQUENCE <expression>...)
X
X The <expression>s are evaluated sequentially from left
X to right, and the value of the last <expression> is
X returned. This expression type is used to sequence side
X effects such as input and output.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME DELAYED EVALUATION Page 12
X
X
X DELAYED EVALUATION
X
X (CONS-STREAM expr1 expr2)
X
X Create a cons stream whose head is expr1 (which is
X evaluated immediately) and whose tail is expr2 (whose
X evaluation is delayed until TAIL is called). To use
X CONS-STREAM, enter the following access procedures:
X
X (define head car)
X (define (tail stream) (force (cdr stream)))
X
X (DELAY <expression>)
X
X Evaluating this expression creates a "promise" to
X evaluate <expression> at a later time.
X
X (FORCE promise)
X
X Applying FORCE to a promise generated by DELAY requests
X that the promise produce the value of the expression
X passed to DELAY. The first time a promise is FORCEed,
X the DELAY expression is evaluated and the value stored.
X On subsequent calls to FORCE with the same promise, the
X saved value is returned.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME ITERATION Page 13
X
X
X ITERATION
X
X (WHILE <test> <expression>...)
X
X While is an iteration construct. Each iteration begins
X by evaluating <test>; if the result is false, then the
X loop terminates and the value of <test> is returned as
X the value of the while expression. If <test> evaluates
X to a true value, then the <expression>s are evaluated in
X order for effect and the next iteration begins.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME DEFINITIONS Page 14
X
X
X DEFINITIONS
X
X (DEFINE <variable> <expression>)
X
X Define a variable and give it an initial value.
X
X (DEFINE (<variable> <formals>) <body>)
X
X Define a procedure.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME LIST FUNCTIONS Page 15
X
X
X LIST FUNCTIONS
X
X (CONS expr1 expr2)
X
X Create a new pair whose car is expr1 and whose cdr is
X expr2.
X
X (CAR pair)
X
X Extract the car of a pair.
X
X (CDR pair)
X
X Extract the cdr of a pair.
X
X (CxxR pair)
X (CxxxR pair)
X (CxxxxR pair)
X
X These functions are short for combinations of CAR and
X CDR. Each 'x' is stands for either 'A' or 'D'. An 'A'
X stands for the CAR function and a 'D' stands for the CDR
X function. For instance, (CADR x) is the same as (CAR
X (CDR x)).
X
X (LIST expr...)
X
X Create a list whose elements are the arguments to the
X function. This function can take an arbitrary number of
X arguments. Passing no arguments results in the empty
X list.
X
X (APPEND list...)
X
X Append lists to form a single list. This function takes
X an arbitrary number of arguments. Passing no arguments
X results in the empty list.
X
X (REVERSE list)
X
X Create a list whose elements are the same as the
X argument except in reverse order.
X
X (LAST-PAIR list)
X
X Return the last pair in a list.
X
X (LENGTH list)
X
X Compute the length of a list.
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME LIST FUNCTIONS Page 16
X
X
X (MEMBER expr list)
X (MEMV expr list)
X (MEMQ expr list)
X
X Find an element in a list. Each of these functions
X searches the list looking for an element that matches
X expr. If a matching element is found, the remainder of
X the list starting with that element is returned. If no
X matching element is found, the empty list is returned.
X The functions differ in the test used to determine if an
X element matches expr. The MEMBER function uses EQUAL?,
X the MEMV function uses EQV? and the MEMQ function uses
X EQ?.
X
X (ASSOC expr alist)
X (ASSV expr alist)
X (ASSQ expr alist)
X
X Find an entry in an association list. An association
X list is a list of pairs. The car of each pair is the
X key and the cdr is the value. These functions search an
X association list for a pair whose key matches expr. If
X a matching pair is found, it is returned. Otherwise,
X the empty list is returned. The functions differ in the
X test used to determine if a key matches expr. The ASSOC
X function uses EQUAL?, the ASSV function uses EQV? and
X the ASSQ function uses EQ?.
X
X (LIST-REF list n)
X
X Return the nth element of a list (zero based).
X
X (LIST-TAIL list n)
X
X Return the sublist obtained by removing the first n
X elements of list.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME DESTRUCTIVE LIST FUNCTIONS Page 17
X
X
X DESTRUCTIVE LIST FUNCTIONS
X
X (SET-CAR! pair expr)
X
X Set the car of a pair to expr. The value returned by
X this procedure is unspecified.
X
X (SET-CDR! pair expr)
X
X Set the cdr of a pair to expr. The value returned by
X this procedure is unspecified.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME SYMBOL FUNCTIONS Page 18
X
X
X SYMBOL FUNCTIONS
X
X (BOUND? sym)
X
X Returns #t if a global value is bound to the symbol and
X #f otherwise.
X
X (SYMBOL-VALUE sym)
X
X Get the global value of a symbol.
X
X (SET-SYMBOL-VALUE! sym expr)
X
X Set the global value of a symbol. The value returned by
X this procedure is unspecified.
X
X (SYMBOL-PLIST sym)
X
X Get the property list associated with a symbol.
X
X (SET-SYMBOL-PLIST! sym plist)
X
X Set the property list associate with a symbol. The
X value returned by this procedure is unspecified.
X
X (GENSYM [sym|str|num])
X
X Generate a new, uninterned symbol. The print name of
X the symbol will consist of a prefix with a number
X appended. The initial prefix is "G" and the initial
X number is 1. If a symbol is specified as an argument,
X the prefix is set to the print name of that symbol. If
X a string is specified, the prefix is set to that string.
X If a number is specified, the numeric suffix is set to
X that number. After the symbol is generated, the number
X is incremented so subsequent calls to GENSYM will
X generate numbers in sequence.
X
X (GET sym prop)
X
X Get the value of a property of a symbol. The prop
X argument is a symbol that is the property name. If a
X property with that name exists on the symbols property
X list, the value of the property is returned. Otherwise,
X the empty list is returned.
X
X (PUT sym prop expr)
X
X Set the value of a property of a symbol. The prop
X argument is a symbol that is the property name. The
X property/value combination is added to the property list
X of the symbol.
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME VECTOR FUNCTIONS Page 19
X
X
X VECTOR FUNCTIONS
X
X (VECTOR expr...)
X
X Create a vector whose elements are the arguments to the
X function. This function can take an arbitrary number of
X arguments. Passing no arguments results in a zero
X length vector.
X
X (MAKE-VECTOR len)
X
X Make a vector of the specified length.
X
X (VECTOR-LENGTH vect)
X
X Get the length of a vector.
X
X (VECTOR-REF vect n)
X
X Return the nth element of a vector (zero based).
X
X (VECTOR-SET! vect n expr)
X
X Set the nth element of a vector (zero based).
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME ARRAY FUNCTIONS Page 20
X
X
X ARRAY FUNCTIONS
X
X (MAKE-ARRAY d1 d2...)
X
X Make an array (vector of vectors) with the specified
X dimensions. At least one dimension must be specified.
X
X (ARRAY-REF array s1 s2...)
X
X Get an array element. The sn arguments are integer
X subscripts (zero based).
X
X (ARRAY-SET! array s1 s2... expr)
X
X Set an array element. The sn arguments are integer
X subscripts (zero based).
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME CONVERSION FUNCTIONS Page 21
X
X
X CONVERSION FUNCTIONS
X
X (SYMBOL->STRING sym)
X
X Convert a symbol to a string. Returns the print name of
X the symbol as a string.
X
X (STRING->SYMBOL str)
X
X Convert a string to a symbol. Returns a symbol with the
X string as its print name. This can either be a new
X symbol or an existing one with the same print name.
X
X (VECTOR->LIST vect)
X
X Convert a vector to a list. Returns a list of the
X elements of the vector.
X
X (LIST->VECTOR list)
X
X Convert a list to a vector. Returns a vector of the
X elements of the list.
X
X (STRING->LIST str)
X
X Convert a string to a list. Returns a list of the
X characters in the string.
X
X (LIST->STRING list)
X
X Convert a list of character to a string. Returns a
X string whose characters are the elements of the list.
X
X (CHAR->INTEGER char)
X
X Convert a character to an integer. Returns the ASCII
X code of the character as an integer.
X
X (INTEGER->CHAR n)
X
X Convert an integer ASCII code to a character. Returns
X the character whose ASCII code is the integer.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME TYPE PREDICATES Page 22
X
X
X TYPE PREDICATE FUNCTIONS
X
X (NOT expr)
X
X Returns #t if the expression is #f and #t otherwise.
X
X (NULL? expr)
X
X Returns #t if the expression is the empty list and #f
X otherwise.
X
X (ATOM? expr)
X
X Returns #f if the expression is a pair and #t otherwise.
X
X (LIST? expr)
X
X Returns #t if the expression is either a pair or the
X empty list and #f otherwise.
X
X (NUMBER? expr)
X
X Returns #t if the expression is a number and #f
X otherwise.
X
X (BOOLEAN? expr)
X
X Returns #t if the expression is either #t or #f and #f
X otherwise.
X
X (PAIR? expr)
X
X Returns #t if the expression is a pair and #f otherwise.
X
X (SYMBOL? expr)
X
X Returns #t if the expression is a symbol and #f
X otherwise.
X
X (COMPLEX? expr)
X
X Returns #t if the expression is a complex number and #f
X otherwise.
X Note: Complex numbers are not yet supported by XScheme.
X
X (REAL? expr)
X
X Returns #t if the expression is a real number and #f
X otherwise.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME TYPE PREDICATES Page 23
X
X
X (RATIONAL? expr)
X
X Returns #t if the expression is a rational number and #f
X otherwise.
X Note: Rational numbers are not yet supported by
X XScheme.
X
X (INTEGER? expr)
X
X Returns #t if the expression is an integer and #f
X otherwise.
X
X (CHAR? expr)
X
X Returns #t if the expression is a character and #f
X otherwise.
X
X (STRING? expr)
X
X Returns # if the expression is a string and #f
X otherwise.
X
X (VECTOR? expr)
X
X Returns #t if the expression is a vector and #f
X otherwise.
X
X (PROCEDURE? expr)
X
X Returns #t if the expression is a procedure (closure)
X and #f otherwise.
X
X (PORT? expr)
X
X Returns #t if the expression is a port and #f otherwise.
X
X (INPUT-PORT? expr)
X
X Returns #t if the expression is an input port and #f
X otherwise.
X
X (OUTPUT-PORT? expr)
X
X Returns #t if the expression is an output port and #f
X otherwise.
X
X (OBJECT? expr)
X
X Returns #t if the expression is an object and #f
X otherwise.
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME TYPE PREDICATES Page 24
X
X
X (EOF-OBJECT? expr)
X
X Returns #t if the expression is the object returned by
X READ upon detecting an end of file condition and #f
X otherwise.
X
X (DEFAULT-OBJECT? expr)
X
X Returns #t if the expression is the object passed as the
X default value of an optional parameter to a procedure
X when that parameter is omitted from a call and #f
X otherwise.
X
X (ENVIRONMENT? x)
X
X Returns #t if the expression is an environment and #f
X otherwise.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME EQUALITY PREDICATES Page 25
X
X
X EQUALITY PREDICATES
X
X (EQUAL? expr1 expr2)
X
X Recursively compares two objects to determine if their
X components are the same and returns #t if they are the
X same and #f otherwise.
X
X (EQV? expr1 expr2)
X
X Compares two objects to determine if they are the same
X object. Returns #t if they are the same and #f
X otherwise. This function does not compare the elements
X of lists, vectors or strings but will compare all types
X of numbers.
X
X (EQ? expr1 expr2)
X
X Compares two objects to determine if they are the same
X object. Returns #t if they are the same and #f
X otherwise. This function performs a low level address
X compare on two objects and may return #f for objects
X that appear on the surface to be the same. This is
X because the objects are not stored uniquely in memory.
X For instance, numbers may appear to be equal, but EQ?
X will return #f when comparing them if they are stored at
X different addresses. The advantage of this function is
X that it is faster than the others. Symbols are
X guaranteed to compare correctly, so EQ? can safely be
X used to compare them.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME ARITHMETIC FUNCTIONS Page 26
X
X
X ARITHMETIC FUNCTIONS
X
X (ZERO? n)
X
X Returns #t if the number is zero and #f otherwise.
X
X (POSITIVE? n)
X
X Returns #t if the number is positive and #f otherwise.
X
X (NEGATIVE? n)
X
X Returns #t if the number is negative and #f otherwise.
X
X (ODD? n)
X
X Returns #t if the integer is odd and #f otherwise.
X
X (EVEN? n)
X
X Returns #t if the integer is even and #f otherwise.
X
X (EXACT? n)
X
X Returns #t if the number is exact and #f otherwise.
X Note: This function always returns #f in XScheme since
X exact numbers are not yet supported.
X
X (INEXACT? n)
X
X Returns #t if the number is inexact and #f otherwise.
X Note: This function always returns #t in XScheme since
X exact numbers are not yet supported.
X
X (TRUNCATE n)
X
X Truncates a number to an integer and returns the
X resulting value.
X
X (FLOOR n)
X
X Returns the largest integer not larger than n.
X
X (CEILING n)
X
X Returns the smallest integer not smaller than n.
X
X (ROUND n)
X
X Returns the closest integer to n, rounding to even when
X n is halfway between two integers.
X
X (1+ n)
X
X
X
X
X
X
X
X
X
X
X XSCHEME ARITHMETIC FUNCTIONS Page 27
X
X
X Returns the result of adding one to the number.
X
X (-1+ n)
X
X Returns the result of subtracting one from the number.
X
X (ABS n)
X
X Returns the absolute value of the number.
X
X (GCD n1 n2)
X
X Returns the greatest common divisor of the two numbers.
X
X (RANDOM n)
X
X Returns a random number between zero and n-1 (n must be
X an integer).
X
X (+ n1 n2...)
X
X Returns the sum of the numbers.
X
X (- n)
X
X Negates the number and returns the resulting value.
X
X (- n1 n2...)
X
X Subtracts each remaining number from n1 and returns the
X resulting value.
X
X (* n1 n2...)
X
X Multiples the numbers and returns the resulting value.
X
X (/ n)
X
X Returns 1/n.
X
X (/ n1 n2...)
X
X Divides n1 by each of the remaining numbers and returns
X the resulting value.
X
X (QUOTIENT n1 n2...)
X
X Divides the integer n1 by each of the remaining numbers
X and returns the resulting integer quotient. This
X function does integer division.
X
X (REMAINDER n1 n2)
X
X Divides the integer n1 by the integer n2 and returns the
X
X
X
X
X
X
X
X
X
X XSCHEME ARITHMETIC FUNCTIONS Page 28
X
X
X remainder.
X
X (MIN n1 n2...)
X
X Returns the number with the minimum value.
X
X (MAX n1 n2...)
X
X Returns the number with the maximum value.
X
X (SIN n)
X
X Returns the sine of the number.
X
X (COS n)
X
X Returns the cosine of the number.
X
X (TAN n)
X
X Returns the tangent of the number.
X
X (ASIN n)
X
X Returns the arc-sine of the number.
X
X (ACOS n)
X
X Returns the arc-cosine of the number.
X
X (ATAN x)
X
X Returns the arc-tangent of x.
X
X (ATAN y x)
X
X Returns the arc-tangent of y/x.
X
X (EXP n)
X
X Returns e raised to the n.
X
X (SQRT n)
X
X Returns the square root of n.
X
X (EXPT n1 n2)
X
X Returns n1 raised to the n2 power.
X
X (LOG n)
X
X Returns the natural logarithm of n.
X
X
X
X
X
X
X
X
X
X
X XSCHEME NUMERIC COMPARISON FUNCTIONS Page 29
X
X
X NUMERIC COMPARISON FUNCTIONS
X
X (< n1 n2...)
X (= n1 n2...)
X (> n1 n2...)
X <<= n1 n2...)
X (>= n1 n2...)
X
X These functions compare numbers and return #t if the
X numbers match the predicate and #f otherwise. For
X instance, (< x y z) will return #t if x is less than y
X and y is less than z.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME BITWISE LOGICAL FUNCTIONS Page 30
X
X
X BITWISE LOGICAL FUNCTIONS
X
X (LOGAND n1 n2...)
X
X Returns the bitwise AND of the integer arguments.
X
X (LOGIOR n1 n2...)
X
X Returns the bitwise inclusive OR of the integer
X arguments.
X
X (LOGXOR n1 n2...)
X
X Returns the bitwise exclusive OR of the integer
X arguments.
X
X (LOGNOT n)
X
X Returns the bitwise complement of n.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME STRING FUNCTIONS Page 31
X
X
X STRING FUNCTIONS
X
X (STRING-LENGTH str)
X
X Returns the length of the string.
X
X (STRING-NULL? str)
X
X Returns #t if the string has a length of zero and #f
X otherwise.
X
X (STRING-APPEND str1...)
X
X Returns the result of appending the string arguments.
X If no arguments are supplied, it returns the null
X string.
X
X (STRING-REF str n)
X
X Returns the nth character in a string.
X
X (SUBSTRING str start end)
X
X Returns the substring of str starting at start and
X ending at end (integers). The range is inclusive of
X start and exclusive of end.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME STRING COMPARISON FUNCTIONS Page 32
X
X
X STRING COMPARISON FUNCTIONS
X
X (STRING<? str1 str2)
X (STRING=? str1 str2)
X (STRING>? str1 str2)
X (STRING<=? str1 str2)
X (STRING>=? str1 str2)
X
X These functions compare strings and return #t if the
X strings match the predicate and #f otherwise. For
X instance, (STRING< x y) will return #t if x is less than
X y. Case is significant. #A does not match #a.
X
X (STRING-CI<? str1 str2)
X (STRING-CI=? str1 str2)
X (STRING-CI>? str1 str2)
X (STRING-CI<=? str1 str2)
X (STRING-CI>=? str1 str2)
X
X These functions compare strings and return #t if the
X strings match the predicate and #f otherwise. For
X instance, (STRING-CI< x y) will return #t if x is less
X than y. Case is not significant. #A matches #a.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME CHARACTER COMPARISON FUNCTIONS Page 33
X
X
X CHARACTER COMPARISON FUNCTIONS
X
X (CHAR<? ch1 ch2)
X (CHAR=? ch1 ch2)
X (CHAR>? ch1 ch2)
X (CHAR<=? ch1 ch2)
X (CHAR>=? ch1 ch2)
X
X These functions compare characters and return #t if the
X characters match the predicate and #f otherwise. For
X instance, (CHAR< x y) will return #t if x is less than
X y. Case is significant. #A does not match #a.
X
X (CHAR-CI<? ch1 ch2)
X (CHAR-CI=? ch1 ch2)
X (CHAR-CI>? ch1 ch2)
X (CHAR-CI<=? ch1 ch2)
X (CHAR-CI>=? ch1 ch2)
X
X These functions compare characters and return #t if the
X characters match the predicate and #f otherwise. For
X instance, (CHAR-CI< x y) will return #t if x is less
X than y. Case is not significant. #A matchs #a.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME INPUT/OUTPUT FUNCTIONS Page 34
X
X
X INPUT/OUTPUT FUNCTIONS
X
X (READ [port])
X
X Reads an expression from the specified port. If no port
X is specified, the current input port is used. Returns
X the expression read or an object that satisfies the
X default-object? predicate if it reaches the end of file
X on the port.
X
X (READ-CHAR [port])
X
X Reads a character from the specified port. If no port
X is specified, the current input port is used. Returns
X the character read or an object that satisfies the
X default-object? predicate if it reaches the end of file
X on the port.
X
X (READ-BYTE [port])
X
X Reads a byte from the specified port. If no port is
X specified, the current input port is used. Returns the
X byte read or an object that satisfies the default-
X object? predicate if it reaches the end of file on the
X port.
X
X (WRITE expr [port])
X (PRIN1 expr [port])
X
X Writes an expression to the specified port. If no port
X is specified, the current output port is used. The
X expression is written such that the READ function can
X read it back. This means that strings will be enclosed
X in quotes and characters will be printed with #
X notation.
X
X (WRITE-CHAR ch [port])
X
X Writes a character to the specified port. If no port is
X specified, the current output port is used.
X
X (WRITE-BYTE ch [port])
X
X Writes a byte to the specified port. If no port is
X specified, the current output port is used.
X
X (DISPLAY expr [port])
X (PRINC expr [port])
X
X Writes an expression to the specified port. If no port
X is specified, the current output port is used. The
X expression is written without any quoting characters.
X No quotes will appear around strings and characters are
X written without the # notation.
X
X
X
X
X
X
X
X
X
X XSCHEME INPUT/OUTPUT FUNCTIONS Page 35
X
X
X (NEWLINE [port])
X
X Starts a new line on the specified port. If no port is
X specified, the current output port is used.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME OUTPUT CONTROL FUNCTIONS Page 36
X
X
X OUTPUT CONTROL FUNCTIONS
X
X (PRINT-BREADTH [n])
X
X Controls the maximum number of elements of a list that
X will be printed. If n is an integer, the maximum number
X is set to n. If it is #f, the limit is set to infinity.
X This is the default. If n is omitted from the call, the
X current value is returned.
X
X (PRINT-DEPTH [n])
X
X Controls the maximum number of levels of a nested list
X that will be printed. If n is an integer, the maximum
X number is set to n. If it is #f, the limit is set to
X infinity. This is the default. If n is omitted from
X the call, the current value is returned.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME FILE I/O FUNCTIONS Page 37
X
X
X FILE I/O FUNCTIONS
X
X All four of the following OPEN functions take an optional
X argument to indicate that file I/O is to be done in binary
X mode. For binary files, this argument should be the symbol
X BINARY. For text files, the argument can be left out or the
X symbol TEXT can be supplied.
X
X (OPEN-INPUT-FILE str ['binary])
X
X Opens the file named by the string and returns an input
X port.
X
X (OPEN-OUTPUT-FILE str ['binary])
X
X Creates the file named by the string and returns an
X output port.
X
X (OPEN-APPEND-FILE str ['binary])
X
X Opens the file named by the string for appending returns
X an output port.
X
X (OPEN-UPDATE-FILE str ['binary])
X
X Opens the file named by the string for input and output
X and returns an input/output port.
X
X (GET-FILE-POSITION port)
X
X Returns the current file position as an offset in bytes
X from the beginning of the file.
X
X (SET-FILE-POSITION! port offset whence)
X
X Sets the current file position as an offset in bytes
X from the beginning of the file (when whence equals 0),
X the current file position (when whence equals 1) or the
X end of the file (when whence equals 2). Returns the new
X file position as an offset from the start of the file.
X
X (CLOSE-PORT port)
X
X Closes any port.
X
X (CLOSE-INPUT-PORT port)
X
X Closes an input port.
X
X (CLOSE-OUTPUT-PORT port)
X
X Closes an output port.
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME FILE I/O FUNCTIONS Page 38
X
X
X (CALL-WITH-INPUT-FILE str proc)
X
X Open the file whose name is specifed by str and call
X proc passing the resulting input port as an argument.
X When proc returns, close the file and return the value
X returned by proc as the result.
X
X (CALL-WITH-OUTPUT-FILE str proc)
X
X Create the file whose name is specifed by str and call
X proc passing the resulting output port as an argument.
X When proc returns, close the file and return the value
X returned by proc as the result.
X
X (CURRENT-INPUT-PORT)
X
X Returns the current input port.
X
X (CURRENT-OUTPUT-PORT)
X
X Returns the current output port.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME CONTROL FEATURES Page 39
X
X
X CONTROL FEATURES
X
X (EVAL expr)
X
X Evaluate the expression in the global environment and
X return its value.
X
X (APPLY proc args)
X
X Apply the procedure to the list of arguments and return
X the result.
X
X (MAP proc list...)
X
X Apply the procedure to argument lists formed by taking
X corresponding elements from each list. Form a list from
X the resulting values and return that list as the result
X of the MAP call.
X
X (FOR-EACH fun list...)
X
X Apply the procedure to argument lists formed by taking
X corresponding elements from each list. The values
X returned by the procedure applications are discarded.
X The value returned by FOR-EACH is unspecified.
X
X (CALL-WITH-CURRENT-CONTINUATION proc)
X (CALL/CC proc)
X
X Form an "escape procedure" from the current continuation
X and pass it as an argument to proc. Calling the escape
X procedure with a single argument will cause that
X argument to be passed to the continuation that was in
X effect when the CALL-WITH-CURRENT-CONTINUATION procedure
X was called.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME ENVIRONMENT FUNCTIONS Page 40
X
X
X ENVIRONMENT FUNCTIONS
X
X (THE-ENVIRONMENT)
X
X Returns the current environment.
X
X (PROCEDURE-ENVIRONMENT proc)
X
X Returns the environment from a procedure closure.
X
X (ENVIRONMENT-BINDINGS env)
X
X Returns an association list corresponding to the top
X most frame of the specified environment.
X
X (ENVIRONMENT-PARENT env)
X
X Returns the parent environment of the specified
X environment.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME UTILITY FUNCTIONS Page 41
X
X
X UTILITY FUNCTIONS
X
X (LOAD str)
X
X Read and evaluate each expression from the specified
X file.
X
X (LOAD-NOISILY str)
X
X Read and evaluate each expression from the specified
X file and print the results to the current output port.
X
X (TRANSCRIPT-ON str)
X
X Opens a transcript file with the specified name and
X begins logging the interactive session to that file.
X
X (TRANSCRIPT-OFF)
X
X Closes the current transcript file.
X
X (EXIT)
X
X Exits from XScheme back to the operating system.
X
X (GC [ni vi])
X
X Invokes the garbage collector and returns information on
X memory usage. If ni and vi are specified, they must be
X integers. Node and vector space are expanded by those
X amounts respectively and no garbage collection is
X triggered. GC returns an array of six values: the
X number of calls to the garbage collector, the total
X number of nodes, the current number of free nodes, the
X number of node segments, the number of vector segments
X and the total number of bytes allocated to the heap.
X
X (RESET)
X
X Returns to the top level read/eval/print loop.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME SYSTEM FUNCTIONS Page 42
X
X
X SYSTEM FUNCTIONS
X
X (%CAR pair)
X (%CDR pair)
X (%SET-CAR! pair expr)
X (%SET-CDR! pair expr)
X (%VECTOR-LENGTH vect)
X (%VECTOR-REF vect n)
X (%VECTOR-SET! vect n expr)
X
X These functions do the same as their counterparts
X without the leading '%' character. The difference is
X that they don't check the type of their first argument.
X This makes it possible to examine data structures that
X have the same internal representation as pairs and
X vectors. It is *very* dangerous to modify objects using
X these functions and there is no guarantee that future
X releases of XScheme will represent objects in the same
X way that the current version does.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X XSCHEME OBJECT REPRESENTATIONS Page 43
X
X
X OBJECT REPRESENTATIONS
X
X This version of XScheme uses the following object
X representations:
X
X Closures are represented as pairs. The car of the
X pair is the compiled function and the cdr of the
X pair is the saved environment.
X
X Compiled functions are represented as vectors. The
X element at offset 0 is the bytecode string. The
X element at offset 1 is the function name. The
X element at offset 2 is a list of names of the
X function arguments. The elements at offsets above 2
X are the literals refered to by the compiled
X bytecodes.
X
X Environments are represented as lists of vectors.
X Each vector is an environment frame. The element at
X offset 0 is a list of the symbols that are bound in
X that frame. The symbol values start at offset 1.
X
X Objects are represented as vectors. The element at
X offset 0 is the class of the object. The remaining
X elements are the object's instance variable values.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
END_OF_FILE
if test 52550 -ne `wc -c <'xscheme.doc'`; then
echo shar: \"'xscheme.doc'\" unpacked with wrong size!
fi
# end of 'xscheme.doc'
fi
echo shar: End of archive 7 \(of 7\).
cp /dev/null ark7isdone
MISSING=""
for I in 1 2 3 4 5 6 7 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 7 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.