From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Tropin Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Add atomic-box-update! function to (ice-9 atomic) Date: Thu, 22 Jun 2023 07:59:38 +0400 Message-ID: <87ttv01711.fsf@trop.in> References: <874jn0pxtz.fsf@trop.in> <47D08644-D34F-43C2-9B0C-24A790F3CEA7@abou-samra.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8572"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel@gnu.org, Andy Wingo To: Jean Abou Samra Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Jun 22 06:00:21 2023 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qCBUb-00020G-2R for guile-devel@m.gmane-mx.org; Thu, 22 Jun 2023 06:00:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCBUB-0004Gl-Ba; Wed, 21 Jun 2023 23:59:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCBU7-0004GY-Kt for guile-devel@gnu.org; Wed, 21 Jun 2023 23:59:51 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCBU4-00060T-Sh for guile-devel@gnu.org; Wed, 21 Jun 2023 23:59:51 -0400 X-GND-Sasl: andrew@trop.in DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1687406385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qooAn1fzNmimCIt6MHOQAqTV4nWmXFIkmIAOzdiEEAg=; b=I5fQKqKnRZJZgeCSd0JdC4jfnuBE6u1BU7ZEnEIiVvwq8dZK/1MpMu8gFRb1khhTn91WWv C+fqA8K4GUo/aRjys47urhHD9MRwbrKZH+0N4jsIkTZQFxJBOeYZga/HCDlABTdHiaq3wr WOyS9i1qhTEvF7JBl5ArswHTlJdfuyaKPSPuao+NR08n/h6s9h5N4WYJ+GjXTrZcjkBMrJ YFxoKbH25McbHBqtIPl0W6XLNRPtEw4Q1Xe+2JKz2Dynld2FXL8eY4JPTkERC2U7Y2BfUH gW8+GZoG2ErTVSkDQ6IaYm4zDmxZq4fDhW/TE7Jfx/HFeLXrGc0mzo+skX1VZQ== X-GND-Sasl: andrew@trop.in X-GND-Sasl: andrew@trop.in Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 64673240002; Thu, 22 Jun 2023 03:59:44 +0000 (UTC) In-Reply-To: <47D08644-D34F-43C2-9B0C-24A790F3CEA7@abou-samra.fr> Received-SPF: pass client-ip=217.70.183.193; envelope-from=andrew@trop.in; helo=relay1-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21872 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2023-06-21 18:54, Jean Abou Samra wrote: >> Le 21 juin 2023 =C3=A0 18:46, Andrew Tropin a =C3=A9cri= t : >>=20 >> 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." >>=20 >> 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. We don't compare boxes here, we compare the underlying values. I'm almost sure that we need eq? here as we need to make sure that the value previously stored and returned atomic-box-compare-and-swap! is the same object in memory, however this example from manual is indeed confusing: =2D-8<---------------cut here---------------start------------->8--- (let ((n (+ 2 3))) (eq? n n)) =3D=3D> _unspecified_ =2D-8<---------------cut here---------------end--------------->8--- So maybe you are right and it's better to use eqv? here. =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmSTxyoACgkQIgjSCVjB 3rC5Rg/+MM1g9ZmywmvBTn4TjolzTwFtQDABeWl59Qoc+E3BkZ0T/kN3f7uPUYEy EhUREZ/yLHnP9+2EYTdNv1Vfh6QCJlGXLpcqfjAF5m7X5H0Hi9wwbV5kR++46Q7X HF7JKuoWd3AzmRUMy17Ln6GAIT+Lz2U04Q+ftIeVT8XiP9PdSMFBqiM5NtMRWfY9 VcT34SceBT0oBEnn0J0RBaYLKRJ4Vf8RNgRPpNP0XpPbscWkOZgetEAih7fbp5Xl 2sIeJzW3KG9meflJer29J4QOIfcrrQ955bZp4GxuYGtDk8ftRlxA+jH001UhPFQp Bktokol7GtCu48G4hvNQE8ijWAOBtYst51CC1VYYMLJl5/xpqdHyBvgUJXZZuzV8 BjbUrDPQGUZErPm/to3olXF8UKUtmXpcdsNHKyfoE5F85c8Xg6p1DodJjFLKC7BU aa+nkA4T9nMHR3UD10rj6xAczILdsAfypLZiOstGj9+x5+vXXBDv1TdE3AsMogcu /tNl4G3d/kPc/eCtunAI1bmReQV9h/oyWOhypQJrW0aqgSpbXEvKXWmmhWEY6mky xGO9xDzgqPvXZSLex/u0q9Dpo1UL1uPGIRkwbmcTCrFOtjDqcPWZ86zptyXZkX5w ABXPJu6pmj5+BgOv6x7ef9tCgLGuuNIHF6QUmYeppL3VFDZFvNU= =sx7P -----END PGP SIGNATURE----- --=-=-=--