(lispkit box)

LispKit is a R7RS-compliant implementation with one exception: pairs are immutable. This library provides implementations of basic mutable data structures with reference semantics: mutable multi-place buffers, also called boxes, and mutable pairs. The difference between a two-place box and a mutable pair is that a mutable pair allows mutations of the two elements independent of each other.

Boxes

Returns #t if obj is a box; #f otherwise.

Returns a new box object that contains the objects obj ....

Returns the current contents of box. If multiple values have been stored in the box, unbox will return multiple values. This procedure fails if box is not referring to a box.

Sets the content of box to objects obj .... This procedure fails if box is not referring to a box.

Invokes proc with the content of box and stores the result of this function invocation in box. update-box! is implemented like this:

(define (update-box! box proc)
  (set-box! box (apply-with-values proc (unbox box))))

Mutable pairs

Returns #t if v is a mutable pair (mpair); #f otherwise.

Returns a new mutable pair whose first element is set to car and whose second element is set to cdr.

Returns the first element of the mutable pair mpair.

Returns the second element of the mutable pair mpair.

Sets the first element of the mutable pair mpair to obj.

Sets the second element of the mutable pair mpair to obj.

Last updated