[plt-scheme] Meaning of set-box!

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Jan 22 17:59:24 EST 2007

On Jan 22, Woodhouse, Gregory J. wrote:
> My understanding is that set-box! is used to modify the contents of
> a box, but neither of these seem to work
> 
> > (define (my-set-bang x a)
>     (set-box! x a))
> > (define x 1)
> > (my-set-bang (box x) 2)
> > x
> 1
> > (set-box! (box x) 2)
> > x
> 1

Just a quick note -- my guess is that you're trying to use `(box x)'
as a replacement for `&x' in C.  If this is not the case then ignore
this post.  But if I'm right, then it might help to know that
`(box x)' is more like

  { p = malloc(size_of(x)); *p = x; return p; }

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.