[racket] Possible bug with "const"?

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Fri Jan 10 14:01:28 EST 2014

On 2014-01-10 13:23:13 -0500, Sean Kanaley wrote:
>    > (define x (build-vector 4 (const (vector 1))))
>
>    > (vector-set! (vector-ref x 2) 0 5)
>
>    > x
>    '#(#(5) #(5) #(5) #(5))

This seems like the right behavior to me.

The documentation for `const` explains that the resulting function
returns the value provided to `const`. The expression `(vector 1)`
evaluates to a value that is a reference to a particular vector in
memory, so all four elements of your vector are references to the same
vector.

Cheers,
Asumu

Posted on the users mailing list.