Next: , Up: System features


4.1.1 Miscellaneous features

The structure features provides some very miscellaneous features in Scheme48.

— procedure: immutable? object –> boolean
— procedure: make-immutable! object –> object

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, and make-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
— procedure: string-hash string –> integer-hash-code

Computes a basic but fast hash of string.

          (string-hash "Hello, world!")           => 1161

— procedure: force-output port –> unspecified

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.

— procedure: current-noise-port –> output-port

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.

— procedure: reverse-list->string char-list count –> string

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.

— procedure: debug-message item ... –> unspecified

Prints item ... directly to an error port,2 eliding buffering and thread synchronization on the Scheme side. Objects are printed as follows:

The code-quote structure exports a variant of quote that is useful in some sophisticated macros.

— special form: code-quote object –> object

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 for quote expressions that do not wrap readable S-expressions: arbitrary, compound, unreadable data may be stored in code-quote. Values computed at compile-time may thus be transmitted to run-time code. However, care should be taken in doing this.


Footnotes

[1] The author of this manual is not at fault for this nomenclature.

[2] On Unix, this is stderr, the standard I/O error output file.

[3] Continuations here are in the sense of VM stack frames, not escape procedures as obtained using call-with-current-continuation.