Next: , Previous: , Up: The Language   [Contents][Index]

4.2 Storage

Function: vector-set-length! object length

Change the length of string, vector, bit-vector, or uniform-array object to length. If this shortens object then the remaining contents are lost. If it enlarges object then the contents of the extended part are undefined but the original part is unchanged. It is an error to change the length of literal datums. The new object is returned.

Function: copy-tree obj
Function: @copy-tree obj

See copy-tree in SLIB. This extends the SLIB version by also copying vectors. Use @copy-tree if you depend on this feature; copy-tree could get redefined.

Function: acons obj1 obj2 obj3

Returns (cons (cons obj1 obj2) obj3).

(set! a-list (acons key datum a-list))

Adds a new association to a-list.

Callback procedure: gc-hook

Allows a Scheme procedure to be run shortly after each garbage collection. This procedure will not be run recursively. If it runs long enough to cause a garbage collection before returning a warning will be printed.

To remove the gc-hook, (set! gc-hook #f).

Function: add-finalizer object finalizer

object may be any garbage collected object, that is, any object other than an immediate integer, character, or special token such as #f or #t, See Immediates. finalizer is a thunk, or procedure taking no arguments.

finalizer will be invoked asynchronously exactly once some time after object becomes eligible for garbage collection. A reference to object in the environment of finalizer will not prevent finalization, but will delay the reclamation of object at least until the next garbage collection. A reference to object in some other object’s finalizer will necessarily prevent finalization until both objects are eligible for garbage collection.

Finalizers are not run in any predictable order. All finalizers will be run by the time the program ends.

This facility was based on the paper by Simon Peyton Jones, et al, “Stretching the storage manager: weak pointers and stable names in Haskell”, Proc. 11th International Workshop on the Implementation of Functional Languages, The Netherlands, September 7-10 1999, Springer-Verlag LNCS.


Next: , Previous: , Up: The Language   [Contents][Index]