A box can be mutable or immutable. When an immutable box is provided to a procedure like set-box!, the exn:fail:contract exception is raised. Box constants generated by the default reader (see Reading Strings) are immutable. Use immutable? to check whether a box is immutable.
box : (and box? (not/c impersonator?))
box : (and/c box? (not/c immutable?) (not/c impersonator?)) v : any/c
Added in version 126.96.36.199 of package base.
box : (and/c box? (not/c immutable?) (not/c impersonator?)) old : any/c new : any/c
except that box-cas! can spuriously fail on some platforms. That is, with low probability, the result can be #f with the value in box left unchanged, even if box contains old.
When Racket is compiled with support for futures, box-cas! is guaranteed to use a hardware compare and set operation. Uses of box-cas! be performed safely in a future (i.e., allowing the future thunk to continue in parallel). See also Machine Memory Order.