Next: Various utilities, Up: System features
The structure features
provides some very miscellaneous features
in Scheme48.
All Scheme objects in Scheme48 have a flag determining whether or not they may be mutated. All immediate Scheme objects (
()
,#f
, &c.) are immutable; all fixnums (small integers) are immutable; and all stored objects — vectors, pairs, &c. — may be mutable.Immutable?
returns#t
if object may not be mutated, andmake-immutable!
, a bit ironically, modifies object so that it may not be mutated, if it was not already immutable, and returns it.(immutable? #t) => #t (define p (cons 1 2)) (immutable? p) => #f (car p) => 1 (set-car! p 5) (car p) => 5 (define q (make-immutable! p)) (eq? p q) => #t (car p) => 5 (immutable? q) => #t (set-car! p 6) error--> immutable pair
Computes a basic but fast hash of string.
(string-hash "Hello, world!") => 1161
Forces all buffered output to be sent out of port.
This is identical to the binding of the same name exported by the
i/o
structure.
The current noise port is a port for sending noise messages that are inessential to the operation of a program.
The silly
structure exports a single procedure, implemented as
a VM primitive for the silly reason of efficiency, hence the name of
the structure.1 It is used in an inner loop of the reader.
Returns a string of the first count characters in char-list, in reverse. It is a serious error if char-list is not a list whose length is at least count; the error is not detected by the VM, so bogus pointers may be involved as a result. Use this routine with care in inner loops.
The debug-messages
structure exports a procedure for emitting
very basic debugging messages for low-level problems.
Prints item ... directly to an error port,2 eliding buffering and thread synchronization on the Scheme side. Objects are printed as follows:
- Fixnums (small integers) are written in decimal.
- Characters are written literally with a
#\
prefix. No naming translation is performed, so the space and newline characters are written literally, not as#\space
or#\newline
.- Records are written as #{type-name}, where type-name is the name of the record's type.
- Strings and symbols are written literally.
- Booleans and the empty list are written normally, i.e. as
#t
,#f
, or()
.- Pairs are written as
(...)
.- Vectors are written as
#(...)
.- Objects of certain primitive types are written as #{type}: procedures, templates, locations, code (byte) vectors, and continuations.3
- Everything else is printed as #{???}.
The code-quote
structure exports a variant of quote
that
is useful in some sophisticated macros.
Evaluates to the literal value of object. This is semantically identical to
quote
, but object may be anything, and the compiler will not signal any warnings regarding its value, while such warnings would be signalled forquote
expressions that do not wrap readable S-expressions: arbitrary, compound, unreadable data may be stored incode-quote
. Values computed at compile-time may thus be transmitted to run-time code. However, care should be taken in doing this.