guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add atomic-box-update! function to (ice-9 atomic)


From: Andrew Tropin
Subject: Re: [PATCH] Add atomic-box-update! function to (ice-9 atomic)
Date: Wed, 21 Jun 2023 20:46:48 +0400

On 2023-06-21 11:06, Jean Abou Samra wrote:

> Le mercredi 21 juin 2023 à 11:06 +0200, Jean Abou Samra a écrit :
>> Le lundi 19 juin 2023 à 16:20 +0400, Andrew Tropin a écrit :
>> > +      (if (eq? old-value (atomic-box-compare-and-swap! box old-value 
>> > new-value))
>> 
>> 
>> Are you sure eq? is a good idea here? (eq? 5 5) is unspecified, for example. 
>> Perhaps eqv? would be more appropriate.
>
> (P.S. And according to the manual, even (let ((a 5)) (eq? a a)) is 
> unspecified.)

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.  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

CCed Andy, I guess he knows the right answer and can explain it.

-- 
Best regards,
Andrew Tropin

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]