From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 20 01:50:05 2023 Received: (at submit) by debbugs.gnu.org; 20 Mar 2023 05:50:06 +0000 Received: from localhost ([127.0.0.1]:53454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pe8PF-0003rj-Ks for submit@debbugs.gnu.org; Mon, 20 Mar 2023 01:50:05 -0400 Received: from lists.gnu.org ([209.51.188.17]:51322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pe8PC-0003rZ-TE for submit@debbugs.gnu.org; Mon, 20 Mar 2023 01:50:03 -0400 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 1pe8PC-000642-Hn for bug-guix@gnu.org; Mon, 20 Mar 2023 01:50:02 -0400 Received: from relay11.mail.gandi.net ([2001:4b98:dc4:8::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pe8PA-0004LG-BA for bug-guix@gnu.org; Mon, 20 Mar 2023 01:50:02 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id B8137100002 for ; Mon, 20 Mar 2023 05:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1679291393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=O3ax6CpS1dfORHGZY7Ubac9RZXLVXsa2Zsb0QJRViq0=; b=fIZaYlaaxlbwYyJD4bSGHIWNX0hoDoKjzptp48DHQdObK2Rmj4JveJb09yefkm1wsTml64 pttcnccYAog/t74U6QE5vQjIvX0nSULuCmsOest1ijsZRsprqRd9tNcW5Oq0l5GDmDGV4Y dP3knIz2mVJypkTbKcmNZg38H/fNlb4A0bZ4Q0aZ7fOvzdNBjVrIba3waZWp6IAslTl5F5 67VlauSP0UGteBmWhn6gdfzeFSRLcNMZT21pUVeBkmHsATpOsZDqyqMjgAqvWNob34UT2D GSkakzmbhqclWpdneaUDmkgmg7bs6xI3QJr+t+1Z02ZMD33KJ3VKrOo/7dShrQ== From: Andrew Tropin To: bug-guix@gnu.org Subject: Ungexp inside vector problem Date: Mon, 20 Mar 2023 09:49:39 +0400 Message-ID: <87v8iw3rbg.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=2001:4b98:dc4:8::231; envelope-from=andrew@trop.in; helo=relay11.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I would expect two last expressions return the same result, but the former one doesn't do ungexp: =2D-8<---------------cut here---------------start------------->8--- (define a '(3 4)) (define b `#(1 2 ,a)) (eval-with-store #~(list '(1 2 #$a))) ;; =3D> ((1 2 (3 4))) (eval-with-store #~(list #(1 2 #$a))) ;; =3D> (#(1 2 (ungexp a))) (eval-with-store #~(list #$b)) ;; =3D> (#(1 2 4)) =2D-8<---------------cut here---------------end--------------->8--- Am I doing/expecting something wrong or there is a bug here? =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQX8/QACgkQIgjSCVjB 3rDkuQ/8D8JqMJ6GRv/+pFUDIvaR1KpVV1UkJmDtoDYNJsPQN1isirrZbtSPYXYt bWEaRsYJapBTB4whqm+Eu3ygqOSBbJq5mfgLV9u2K54Lij0nHVRqW1a/8Cz163zW RStimNJ/6R2XchrBB9FouXIXbPuIDzGTGYC97F1JkEOYHX0fEd++9N/L0QgieF8w bc4nA1UyoosEnnqoFTpu3RIQF53oQ1xSmUBXpu9hYqr3bsjM/MdqbUGD36BRgIoH iVgki+pV7brIyLJ5pO7bJKW8mS1Hm+vAtJTz25g/h8R9qtOha37YsQETScS6Nc0x zImc0RkiZHSY+Qj8yC5WuJIfajKPBY1/0ElzNGB75kqDmyQt12ixX7xZGe0GMzZU Syvov8wuEwflRsWv8KyjX1P1iLO8Hi1BSYYbo7MBUKhT2E5JTcY0Gl1VNw2LS79w f3WT9CrcijVus0qkmYVdi0iBOBAKBruDP9ui3PdyRyVg1tACJowB5nitT2UrhPYU E68/XYiaCnAlFENbC4CtCHC4jv4XvSrCBHo5tV5qLbKae9oq0e0GYgZOEGGlZtZ6 2sVtTdZvJj2Hc4mwLQ72x1LOtPl5JWD81bm4mDq+KCSIBeksF8cltwB/mxvs/ScU WcA5+px2IcNM3nvZblDQYgXkng4/vT9SiXlIzlcPJzc48L/5p34= =RioR -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 20 06:45:21 2023 Received: (at 62287) by debbugs.gnu.org; 20 Mar 2023 10:45:21 +0000 Received: from localhost ([127.0.0.1]:53746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peD0y-0007yc-N9 for submit@debbugs.gnu.org; Mon, 20 Mar 2023 06:45:21 -0400 Received: from jpoiret.xyz ([206.189.101.64]:46908) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1peD0w-0007yT-98 for 62287@debbugs.gnu.org; Mon, 20 Mar 2023 06:45:19 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 301C7184BEE; Mon, 20 Mar 2023 10:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1679309116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FGWYZNyh5C0FwmkPSubuXzZpelxnM+fwy9HPUWF6cfs=; b=cTm33On74XGTF9gENsodYp3R+SyAz/z6nV/rQ+7p/S3kcvpIWQrwaKSf2NPDhOFXdZMvpy DwwN4KO7nMzYe/b1VAIrMUWdr7SHOvBKDbu7Ga3B9Ko7Qu7+hrouXRi0ZnuF6aGge45Zlc z/hN1xdoLaPTn6zU2jVG+f4MNtmKN0xl0RzSLFb4ZO6unpCurEc7I8vN1pHyON0M7MEwJf jSukwoA/EEbDnaVWgGz2Tk/Fm7V2bETT4BFBxWVyk8b39s/dr6aSEY7Uk34AD2LIalFlWb ZlrJ11tRCcU1krs66sDCBQH6hL9n+qfdw2dA9W5mCA2Q8lxeNPVwzOVE3CTWuA== From: Josselin Poiret To: Andrew Tropin , 62287@debbugs.gnu.org Subject: Re: bug#62287: Ungexp inside vector problem In-Reply-To: <87v8iw3rbg.fsf@trop.in> References: <87v8iw3rbg.fsf@trop.in> Date: Mon, 20 Mar 2023 11:45:11 +0100 Message-ID: <875yavsnuw.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62287 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Andrew, Andrew Tropin writes: > I would expect two last expressions return the same result, but the > former one doesn't do ungexp: > > --8<---------------cut here---------------start------------->8--- > (define a '(3 4)) > > (define b `#(1 2 ,a)) > > (eval-with-store > #~(list '(1 2 #$a))) ;; =3D> ((1 2 (3 4))) > > (eval-with-store > #~(list #(1 2 #$a))) ;; =3D> (#(1 2 (ungexp a))) > > (eval-with-store > #~(list #$b)) ;; =3D> (#(1 2 4)) > --8<---------------cut here---------------end--------------->8--- > > Am I doing/expecting something wrong or there is a bug here? It's more related to how the guile reader works, and this is such a corner case that I don't know whether we should fix. Basically, anything starting with # is a reader extension, and the next character identifies which extension it is. #( is the reader extension for vectors, #~ for gexp and #$ for ungexp. To simplify, whenever you use #~, guile will insert (gexp ...) instead, which is a hygienic macro (not just a procedure!), that will look for ungexps inside the expression. That traversal is only made on cons cells though, so it doesn't try to go through any piece of syntax that is not a cons cell! Since #( doesn't expand to a (vector ...) cons-cell, the subexpression gets ignored for traversal. This is in contrast to another reader extension, #' (for syntax), which does expand to (syntax ...), and is thus further traversed! You can find how both of these reader extensions operate in . I guess the immediate fix is to use (vector ...) rather than #(...). We could also add code to the gexp traversal to also traverse vectors, but I am not even sure if they go through the gexp->sexp dance unharmed, and we also should in principle do that for everything that can get into a gexp, not just vectors (eg. bytevectors). Best, =2D-=20 Josselin Poiret --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHEBAEBCAAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmQYOTcQHGRldkBqcG9p cmV0Lnh5egAKCRBQXkC5FhcaimIGC/9UazBvJmF/Mwufblx4XfuVV2UhkFAmvj8Q DI6j39wa6lU4ILgxuN64Bw9qmreityeJH+gRS3mjP5Cjpg5wVEKCqxfiEMVzt/aZ TJCG/BEAwpQCvNh0n/mDt5I6nwCYlLfUkoilI4oIvk+2CksDLAX0Z5c0XHNLCrPo mQQaq00qllMmpWAl2xOblSOa3guYh549QzJxuA0bx+usY0RE9LPUgIL2yZFLMo/A kCkqPfv0SJPH+Oq5Yn0SNgBpMUUJtoaIMP3Wv6PhzDuZ5IC/8YdC7KR4Pk48a6r3 yvesdch64ywCgTKbJ44LjHj8SLr7ya2R6haUYrf1evIquOOVB+itmEeoyYhiYmCu DRAeBW1vpSfjrdkBRBgFUc5vFa9O9C/mOPJ+53sbRJQF2G2mZVAFmc+Yp/U4MUnQ KkMgJrPwTWjnWHoIH3w9BOukNgK+t9WVqpkPaaFlHTBmeOBbncbgOqFmuDJiu/ko Tk8uWDXTaeO6wZ6RxbQUf9ZAo6zX0Q0= =oVql -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 14 22:57:25 2023 Received: (at 62287) by debbugs.gnu.org; 15 Jun 2023 02:57:25 +0000 Received: from localhost ([127.0.0.1]:45851 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9dAr-0001uG-0k for submit@debbugs.gnu.org; Wed, 14 Jun 2023 22:57:25 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:50429) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9dAp-0001ty-Ai for 62287@debbugs.gnu.org; Wed, 14 Jun 2023 22:57:24 -0400 X-GND-Sasl: andrew@trop.in DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1686797837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=v8gI7mhqqyM3q4GnRLu3kiJUy4Y45tVlmsSxRjBkd7A=; b=NQmk1vzP5NkeVmcYQutcBPZ6MY9/kHqs613y75jZc/OFOPErQxQR9zyK9vFoBCXIfRJbkN j8bverywkpc1isLCvM8AIjUWsvIabEhG7vW9/vxexrO64b66fdPz+xZqIxWYI2twzH0coi zku2cmCU1YjqMouKQx52cvKIx2w9reft4oJNGqkeT/MmQsCyqAf4Lac//N+CNHIxQJGKMW VEhKyjCSoDgBQDq1M1AzyREBKrNNj3NkbfzJMrLssuIzuQJItL/TxamVj7F6U3k9ljNAJ5 F7ZFp3GiL4i3dcG9BvbRfv0LXPEZ12fOsoOci9TDbOgtvlu6uCpKw3VprNcxiQ== X-GND-Sasl: andrew@trop.in Received: by mail.gandi.net (Postfix) with ESMTPSA id B3441240004; Thu, 15 Jun 2023 02:57:16 +0000 (UTC) From: Andrew Tropin To: Josselin Poiret , 62287@debbugs.gnu.org Subject: Re: bug#62287: Ungexp inside vector problem In-Reply-To: <875yavsnuw.fsf@jpoiret.xyz> References: <87v8iw3rbg.fsf@trop.in> <875yavsnuw.fsf@jpoiret.xyz> Date: Thu, 15 Jun 2023 06:57:12 +0400 Message-ID: <87edmdh1pz.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62287 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2023-03-20 11:45, Josselin Poiret wrote: > Hi Andrew, > > Andrew Tropin writes: > >> I would expect two last expressions return the same result, but the >> former one doesn't do ungexp: >> >> --8<---------------cut here---------------start------------->8--- >> (define a '(3 4)) >> >> (define b `#(1 2 ,a)) >> >> (eval-with-store >> #~(list '(1 2 #$a))) ;; =3D> ((1 2 (3 4))) >> >> (eval-with-store >> #~(list #(1 2 #$a))) ;; =3D> (#(1 2 (ungexp a))) >> >> (eval-with-store >> #~(list #$b)) ;; =3D> (#(1 2 4)) >> --8<---------------cut here---------------end--------------->8--- >> >> Am I doing/expecting something wrong or there is a bug here? > > It's more related to how the guile reader works, and this is such a > corner case that I don't know whether we should fix. Basically, > anything starting with # is a reader extension, and the next character > identifies which extension it is. #( is the reader extension for > vectors, #~ for gexp and #$ for ungexp. > > To simplify, whenever you use #~, guile will insert (gexp ...) instead, > which is a hygienic macro (not just a procedure!), that will look for > ungexps inside the expression. That traversal is only made on cons > cells though, so it doesn't try to go through any piece of syntax that > is not a cons cell! Since #( doesn't expand to a (vector ...) > cons-cell, the subexpression gets ignored for traversal. > > This is in contrast to another reader extension, #' (for syntax), which > does expand to (syntax ...), and is thus further traversed! > > You can find how both of these reader extensions operate in > . > > I guess the immediate fix is to use (vector ...) rather than #(...). We > could also add code to the gexp traversal to also traverse vectors, but > I am not even sure if they go through the gexp->sexp dance unharmed, and > we also should in principle do that for everything that can get into a > gexp, not just vectors (eg. bytevectors). > Thank you very much for extensive explanation! I have a few tasks related to the guile reader extensions, so when I get my hands dirty with it, I'll probably share my new thoughts and opinions on this topic. =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmSKfggACgkQIgjSCVjB 3rC66A//WKBxTBLKv9zB80gtSCAG/D5IB8fidUHVPc22ih+t7Yi4MreNBOp4Oce9 O/0pbc/rolBfpm1CrYnX/Ug/j10miq7gpwZYKR6neO2iS6zpMee/hta2RBgCHGSS toBBLk+D+mUdWNk70vy1ZKXxPPBVw8pYA1yZ0YusPvTuy83CPAq8HbFgj6RK3iAB QGxjui+XCUP9vYUZGsCk1YlVbN9E1qGWxfbxvEXudB1XuZ1widj+SxRN0i1Arq5n cmPUq0+rI/Bq7247myIKDolCcAOEumqJttsM+Mw9pD28e1CI6EiYxxD/adxrM8NQ /7eEeiLzsR3Sj4SC9uOlDoEreiAbUCU+Wy4bencDBn8Vv07MkeOzriu/+qgxCSr0 P9WnjdU/qGmHQ0aZLTcRFEhbwQgKh2Em/hmheC1qtffGn46GMVHGKdzRyLEsM3Kg y0SWMgh1qwv/ELQUVACLcoLtdGX0ibzBBfY8IMHboF6Kes8AeQW45DcBtW2N76TB xkH/qMVBgJDzBgZauQT9vs7/mQEwrD+Qawkx9hrSBa0/1nZjVTkBo9w2nTro5Zx/ 4LP60t7klfpbzSXS1sQc9TWUj5qCzMDIg2953t6UrtCeup4sjltPyGvqriFKF1mX L3VM5cOvAoTkQal4JSYzLdfDEU8FmKE0mBXsKrdIagzqA9UbHt8= =yxjj -----END PGP SIGNATURE----- --=-=-=--