Hi Bil,

I stumbled upon something interesting:

(let ()
  (define x #(0 0))
  (define (reset)
    (set! x #(0 0)))

  (set! (x 0) 1)
  (reset)
  (set! (x 1) 2)
  (reset)
  x)

The x being returned is #(0 2).

(Let's ignore the inefficient reset code).

I'm guessing that in the reset lambda the #(0 0) is expanded to a cell
which is captured in the lambda body & reused later on.
Checking with guile, it complains about vector-set!: Wrong type argument in
position 1 (expecting mutable vector): #(0 0)
So apparently in guile with (define x #(0 0)), x is an immutable vector.

Hope this is helpful, not like yesterday!
_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to