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.
#tif obj is a box;
(box obj ...)
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,
unboxwill return multiple values. This procedure fails if box is not referring to a box.
(set-box! box obj ...)
Sets the content of box to objects obj .... This procedure fails if box is not referring to a box.
(update-box! box proc)
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))))
#tif v is a mutable pair (mpair);
(mcons car cdr)
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.
(set-mcar! mpair obj)
Sets the first element of the mutable pair mpair to obj.
(set-mcdr! mpair obj)
Sets the second element of the mutable pair mpair to obj.