> Le 21 juin 2023 à 18:46, Andrew Tropin <and...@trop.in> a écrit :
>
> Make sense, but it's hard for me to say something valuable on this
> topic. Usually, I don't use eq? and don't have enough knowledge of its
> internals.
*Currently*, it just checks whether the two C-level SCM values are the same
bitwise, so even implicit copies of fixnums will remain eq?. In theory, Guile
could make copies of bignums. I am not aware of it doing so.
However, all that is guaranteed is that (eq? a a) when a is a non-immediate
(pair, string, vector, hashtable, etc) or one of a few constants like booleans,
the empty list and *unspecified*. Notably, it isn't guaranteed for numbers or
characters.
> I went the way suggested by the manual: "Returns the
> previous value of the box in either case, so you can know if the swap
> worked by checking if the return value is eq? to expected."
>
> https://www.gnu.org/software/guile/manual/html_node/Atomics.html
As long as you use boxes for values for which eq? is well-defined, that is
fine. I guess this would cover most cases, although I'm not familiar with this
module.
But in general, eqv? seems saner.