Den fre. 25. okt. 2019 kl. 16.35 skrev wanderley.guimar...@gmail.com < wanderley.guimar...@gmail.com>:
> Why (eq? (quote a) (quote a)) is #t but (eq? (quote (a)) (quote (a))) > is #f? I would expect that if (quote (a)) was a mutable pair but it > is not since (quote (a)) returns #f. It seems that guile returns #t > as I was expecting. > Racket (and Scheme) interns symbol literals. That is, if you put the literal '(foo foo) in your code you will get a list value of length two, its elements are both the same symbol spelled foo. On the other hand in Scheme '("foo" "foo") will get you a list value of length two. The elements of the lists are two strings, which may or may not be the same string (since strings are neither guaranteed to be interned (nor not to be interned) in Scheme). If the same literal appears twice in the source code some Scheme implementations will use the same value twice. So in '(foo) '(foo) the two list literals may or may not return the same value. List values aren't guaranteed to be interned, so (eq? '(foo) '(foo)) may or may not return true in a Scheme implementation. Note that this explains why Schemers write (define magic (list 'magic)) and not (define magic '(magic)) in order to obtain a unique value, not eq? to any other value. In order to allowing implementations to share values in literals in R5RS it is unspecified what happens when you mutate a literal. /Jens Axel -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CABefVgyZ5TUABV%2Baw6G0vtohjeuJ0NXZPG0Ju3U4wXAK_o%3Dsnw%40mail.gmail.com.