MIT Scheme implements the whole tower of numerical types. It has unlimited-precision exact integers and exact rationals. Flonums are used to implement all inexact reals; on machines that support IEEE floating-point arithmetic these are double-precision floating-point numbers.
MIT Scheme implements all of the written notations for numbers.
In MIT Scheme the rational?
procedure is the
same as real?
, and the complex?
procedure is the same as
number?
.
MIT Scheme signals an error of type
condition-type:bad-range-argument
in this case.
Some of the details in this section depend on the fact that the underlying operating system uses the ASCII character set. This may change when someone ports MIT Scheme to a non-ASCII operating system.
Note that the Control bucky bit is different from
the ASCII control key. This means that #\SOH
(ASCII
ctrl-A) is different from #\C-A
. In fact, the Control bucky bit
is completely orthogonal to the ASCII control key, making possible
such characters as #\C-SOH
.
Because character sets are implemented as strings,
string?
returns #t
for character set objects. However,
string operations aren't meaningful with character sets.
The above definitions imply that all lists have finite length and are terminated by the empty list.
Note that path is restricted to a machine-dependent range, usually the size of a machine word. On many machines, this means that the maximum length of path will be 30 operations (32 bits, less the sign bit and the "end-of-sequence" bit).
Although
they are often used as predicates, memq
, memv
, and
member
do not have question marks in their names because they
return useful values rather than just #t
or #f
.
In older dialects of Lisp, uninterned symbols were fairly important. This was true because symbols were complicated data structures: in addition to having value cells (and sometimes, function cells), these structures contained property lists. Because of this, uninterned symbols were often used merely for their property lists -- sometimes an uninterned symbol used this way was referred to as a disembodied property list. In MIT Scheme, symbols do not have property lists, or any other components besides their names. There is a different data structure similar to disembodied property lists: one-dimensional tables (see section 1D Tables). For these reasons, uninterned symbols are not very useful in MIT Scheme. In fact, their primary purpose is to simplify the generation of unique variable names in programs that generate Scheme code.
MIT Scheme
reserves a specific set of interned symbols for its own use. If you use
these reserved symbols it is possible that you could break specific
pieces of software that depend on them. The reserved symbols all have
names beginning with the characters `#[' and ending with the
character `]'; thus none of these symbols can be read by the
procedure read
and hence are not likely to be used by accident.
For example, (intern "#[unnamed-procedure]")
produces a reserved
symbol.
In MIT Scheme, the returned list is always newly allocated.
The variable the-empty-stream
,
which is bound to the end-of-stream marker, is provided for
compatibility with old code; use (stream)
in new code.
head
, a synonym for
stream-car
, is provided for compatibility with old code; use
stream-car
in new code.
tail
, a synonym for
stream-cdr
, is provided for compatibility with old code; use
stream-cdr
in new code.
empty-stream?
, a synonym for
stream-null?
, is provided for compatibility with old code; use
stream-null?
in new code.
This introduction is taken from Common Lisp, The Language, second edition, p. 431.
Although they are often used as predicates,
assq
, assv
, and assoc
do not have question marks in
their names because they return useful values rather than just #t
or #f
.
Because Scheme's escape
procedures have unlimited extent, it is possible to escape from the
current continuation but later to escape back in. If implementations
were permitted to close the port on any escape from the current
continuation, then it would be impossible to write portable code using
both call-with-current-continuation
and
call-with-input-file
or call-with-output-file
.
The value returned by a call to peek-char
is the same as the value that would have been returned by a call to
read-char
on the same port. The only difference is that the very
next call to read-char
or peek-char
on that
input-port will return the value returned by the preceding call to
peek-char
. In particular, a call to peek-char
on an
interactive port will hang waiting for input whenever a call to
read-char
would have hung.
char-ready?
exists to make it possible for a
program to accept characters from interactive ports without getting
stuck waiting for input. Any input editors associated with such ports
must make sure that characters whose existence has been asserted by
char-ready?
cannot be rubbed out. If char-ready?
were to
return #f
at end of file, a port at end of file would be
indistinguishable from an interactive port that has no ready
characters.
write
is
intended for producing machine-readable output and display
is for
producing human-readable output.
This description of format
is adapted from
Common Lisp, The Language, second edition, section 22.3.3.
Except that if the
argument name is a string, its external representation is
generated by write-string
.
This introduction is adapted from Common Lisp, The Language, second edition, section 23.1.
This description is adapted from Common Lisp, The Language, second edition, section 23.1.1.