[racket] Possible bug with "const"?

From: Sean Kanaley (skanaley at gmail.com)
Date: Fri Jan 10 13:23:13 EST 2014

> (define x (build-vector 4 (const (vector 1))))

> (vector-set! (vector-ref x 2) 0 5)

> x
'#(#(5) #(5) #(5) #(5))

-------- vs. --------------

> (define x (build-vector 4 (λ (x) (vector 1))))

> (vector-set! (vector-ref x 2) 0 5)

> x
'#(#(1) #(1) #(5) #(1))

---------------------------------------------------------------

Maybe I'm misunderstanding const, but to me it means "ignore arguments" as
opposed to signifying shared-structure / immutability (like a "constant").
That's what #(1) is for.  The top version should I believe constantly
return a fresh (different) vector regardless of its arguments.

I'm on 5.3.4 due to Ubuntu, in case this was already found.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140110/62386225/attachment.html>

Posted on the users mailing list.