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