Boxes in The Racket Guide introduces boxes.
A box is like a single-element vector, normally used as
minimal mutable storage.
A literal or printed box starts with #&. See Reading Boxes
for information on reading
boxes and Printing Boxes
for information on printing boxes.
Returns #t if v is a box, #f otherwise.
Returns a new mutable box that contains v.
Returns a new immutable box that contains v.
Returns the content of box.
For any v, (unbox (box v)) returns v.
Sets the content of box to v.
Added in version 184.108.40.206 of package base.
Atomically updates the contents of box
currently contains a value that is eq?
, and returns #t
in that case. If box
does not contain old
, then the result is #f
If no other threads or futures attempt to access
box, the operation is equivalent to
(and (eq? old (unbox loc)) (set-box! loc new) #t)
When Racket is compiled with support for futures,
box-cas! uses 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).