7.7
4.8 Boxes
A box is a single (im)mutable storage cell, which behaves like a one-element (im)mutable vector . Like vectors, immutable boxes are treated as transparent immutable values: they are eq? when their contents are eq?. Mutable boxes are references rather than values, so they are eq? only when they point to the same box object. Boxes can be concrete or symbolic, and they can contain both symbolic and concrete values.
Examples:
> (define v1 (box 1)) > (define v2 (box 1)) > (eq? v1 v2) #f
> (equal? v1 v2) #t
> (define v3 (box-immutable 1)) > (define v4 (box-immutable 1)) > (eq? v3 v4) #t
> (equal? v1 v3) #t
Examples:
> (define-symbolic x integer?) > (define-symbolic b boolean?) > (define v1 (box x)) ; v1 is a box with symbolic contents > (define v2 (if b v1 (box 3))) ; v2 is a symbolic box > (define sol (solve (assert (= 4 (unbox v2))))) > (evaluate v1 sol) '#&4
> (evaluate v2 sol) '#&4
> (evaluate (eq? v1 v2) sol) #t
Lifted box operations are shown below.