[plt-scheme] Immutable boxes: why?
On Jun 11, Luciano Ramalho wrote:
> My understanding of the box datatype was shaken when I read [1] that
> there is an "immutable box" constructor:
>
> (box-immutable v)
>
> [1] http://docs.plt-scheme.org/reference/boxes.html
>
> Can someone please explain what is the use of an immutable box?
It's useful in literals. Try this in PLT v3xx, and then in v4.x:
(define (foo)
(let ([b #&0])
(set-box! b (add1 (unbox b)))
(unbox b)))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!