ELI5 the fine points of eq?
I don't seem to understand the nuances of eq?. According to the Racket Reference,
The eq? operator compares two values, returning #t when the values refer to the same object. This form of equality is suitable for comparing objects that support imperative update (e.g., to determine that the effect of modifying an object through one reference is visible through another reference).
That seems to mean that if two identifiers are eq?, then set!ing one will necessarily change the value of the other. But the following code ...
(define a 3)
(define b (+ 1 1 1))
(define c a)
(list (eq? a b)
(eq? a c))
(set! a 10)
(list a b c)
... gives me,
'(#t #t)
'(10 3 3)
As I understand it, a and b should not be eq? in the first place, but modifying a should also modify the others because they are all in fact eq?. What am I missing?
Posted May 29, 2016, 7:31 PM UTC
85