Next: , Previous: , Up: srfi boxes   [Index]


2.35.3 Specification

The following procedures implement the box type (which is disjoint from all other Scheme types), and are exported by the libraries (srfi :111) and (srfi :111 boxes).

Function: box obj

Constructor. Return a newly allocated box initialized to obj.

Function: box? obj

Predicate. Return #t if obj is a box, and #f otherwise.

Function: unbox box/obj

Accessor. Return the current value of box/obj.

For Vicare: if box/obj is not a box object, no error is raised and the return value is box/obj itself.

Function: set-box! box new-obj

Mutator. Change box to hold new-obj.

The behavior of boxes with the equivalence predicates eq?, eqv?, and equal? is the same as if they were implemented with records. That is, two boxes are both eq? and eqv? if, and only if, they are the product of the same call to box and not otherwise, and while they must be equal? if they are eqv?, the converse is implementation–dependent.

For Vicare: two boxes produced by distinct call to box and holding the same object are equal? but not eqv?.

Autoboxing (optional)

The following provisions of this SRFI are optional:


Next: , Previous: , Up: srfi boxes   [Index]