-----

Scheme48 libraries

-----

The following is a short list of useful code that comes with scheme48. Definitions of these packages can be found in the files rts-packages.scm, comp-packages.scm, and more-packages.scm in the distribution directory. The bindings they export are listed in interfaces.scm and more-interfaces.scm.

architecture
Information about the virtual machine. E.g. (enum op eq?) => the integer opcode of the EQ? instruction

arrays
Arrays. See comments at the top of file big/array.scm.

ascii
CHAR->ASCII and ASCII->CHAR. Similar to CHAR->INTEGER and INTEGER->CHAR except that ASCII encoding is guaranteed.

big-scheme
Many generally useful features.

bigbit
Extensions to the bitwise logical operators (exported by the BITWISE structure) so that they operate on bignums. To use these you should do
        ,load-package bigbit
	,open bitwise

bitwise
Bitwise logical operators.

conditions
Part of the condition system: DEFINE-CONDITION-PREDICATE and routines for examining condition objects. (See also handle, signals.)

define-record-types
A DEFINE-RECORD-TYPE macro, providing a concise front end to the record package. (Richard and Jonathan favor different record type defining macros; this one is Jonathan's.)

The general syntax is:

      (define-record-type <tag> <type-name>
        (<constructor-name> <field-tag>*)
	<predicate-name>
	(<field-tag> <accessor-name> [<modifier-name>])*)

Example:

      (define-record-type pare :pare
        (kons x y)
	pare?
	(x kar set-kar!)
	(y kdr))
This defines KONS to be a constructor, KAR and KDR to be accessors, SET-KAR! to be a modifier, and PARE? to be a predicate for a new type of object. The type itself is named :PARE. PARE is a tag used in printing the new objects. The field tags X and Y are used in the inspector and to match constructor arguments with fields.

By default, the new objects print as #{Pare}. The print method can be modified using DEFINE-RECORD-DISCLOSER:

      (define-record-discloser :pare
        (lambda (p) `(pare ,(kar p) ,(kdr p))))

defpackage
The module system: DEFINE-STRUCTURE and DEFINE-INTERFACE.

defrecord
A define-record-type macro, providing more concise use of the record package. (Richard and Jonathan favor different record type defining macros; this one is Richard's.)

destructuring
DESTRUCTURE macro.

display-conditions
Displaying condition objects.
        (DISPLAY-CONDITION condition port) => unspecific
	  Display condition in an easily readable form.  E.g.
	  > ,open display-conditions handle conditions
	  > (display-condition
	     (call-with-current-continuation
	       (lambda (k)
		 (with-handler (lambda (c punt)
				 (if (error? c)
				     (k c)
				     (punt)))
		   (lambda () (+ 1 'a)))))
	     (current-output-port))

	  Error: exception
		 (+ 1 'a)
	  > 

enumerated
Enumerated types.

extended-ports
Ports for reading from and writing to strings, and related things.

externals
Rudimentary external function interface.

filenames
Rudimentary file name parsing and synthesis. E.g. file-name-directory and file-name-nondirectory are as in Gnu emacs.

floatnums
Floating point numbers. These are in a very crude state; use at your own risk. They are slow and do not read or print correctly.

fluids
Dynamically bound "variables."
      (MAKE-FLUID top-level-value) => a "fluid" object
      (FLUID fluid) => current value of fluid object
      (SET-FLUID! fluid value) => unspecific; changes current value of
        fluid object
      (LET-FLUID fluid value thunk) => whatever thunk returns

Within the dynamic extent of execution of (thunk), the fluid object has value as its binding (unless changed by SET-FLUID! or overridden by another LET-FLUID). E.g.

      (define f (make-fluid 7))
      (define (baz) (+ (fluid f) 1))
      (baz)   ;=> 8
      (let-fluid f 4 (lambda () (+ (baz) 1)))  ;=> 6

formats
A simple FORMAT procedure, similar to Common Lisp's or T's.

general-tables
An extended version of TABLES; supports tables keyed by strings.

handle
Part of the condition system.
      (WITH-HANDLER handler thunk) => whatever thunk returns.

Handler is a procedure of two arguments. The first argument is a condition object, and the second is a "punt" procedure. The handler should examine the condition object (using ERROR?, etc. from the CONDITIONS structure). If it decides not to do anything special, it should tail-call the "punt" procedure. Otherwise it should take appropriate action and perform a non-local exit. It should not just return unless it knows damn well what it's doing; returns in certain situations can cause VM crashes.

interrupts
Interrupt system

more-threads
Interface between multitasking and the command processor. Try this:
	,open threads more-threads
	(start-threads)
	(spawn (lambda () (display "Hello ")))

ports
A few extra port-related operations, notably FORCE-OUTPUT.

pp
A pretty-printer. (p <exp>) will pretty-print the result of <exp>, which must be an S-expression. (Source code for procedures is not retained or reconstructed.) You can also do (p <exp> <port>) to print to a specific port.

The procedure pretty-print takes three arguments: the object to be printed, a port to write to, and the current horizontal cursor position. If you've just done a newline, then pass in zero for the position argument.

The algorithm is very peculiar, and sometimes buggy.

queues
FIFO queues.

random
Random number generator.
        > (define random (make-random <seed>))
	> (random)  =>  a pseudo-random number between 0 and 2^28

receiving
Convenient interface to the call-with-values procedure, like Common Lisp's multiple-value-bind macro.

records
MAKE-RECORD-TYPE and friends. See the Scheme of Things column in Lisp Pointers, volume 4, number 1, for documentation.

recnums
Complex numbers. This should be loaded (e.g. with ,load-package) but needn't be opened.

search-trees
Balanced binary search trees. See comments at top of big/search-tree.scm.

signals
ERROR, WARN, and related procedures.

sort
Online merge sort (see comment at top of file big/sort.scm).
        (sort-list <list> <pred>)
	(sort-list! <list> <pred>)

sicp
Compatibility package for the Scheme dialect used in the book "Structure and Interpretation of Computer Programs."

sockets
Interface to Unix BSD sockets. See comments at top of file misc/socket.scm.

tables
Hashed association tables. Keys are compared using EQ?.

threads
Multitasking.

util
SUBLIST, ANY, REDUCE, FILTER, and some other useful things.

weak
Weak pointers and populations.
        (MAKE-WEAK-POINTER thing) => weak-pointer
	(WEAK-POINTER-REF weak-pointer) => thing or #F
	  #F if the thing has been gc'ed.

writing
        (RECURRING-WRITE thing port recur) => unspecific

This is the same as WRITE except that recursive calls invoke the recur argument instead of WRITE. For an example, see the definition of LIMITED-WRITE in env/dispcond.scm, which implements processing similar to common Lisp's *print-level* and *print-length*.

-----

Ownership, Maintenance and Disclaimers

Scheme48 Manual Top Page

Envision Manual Top Page

Last modified