From unknown Sun Jun 22 11:42:12 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14203: Manual: 'my-or'; 'let' inside macros Resent-From: Nikita Karetnikov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 14 Apr 2013 16:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14203 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 14203@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.136595729832249 (code B ref -1); Sun, 14 Apr 2013 16:35:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Apr 2013 16:34:58 +0000 Received: from localhost ([127.0.0.1]:50374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URPtK-0008O6-1Q for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:34:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57217) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URPtH-0008Nz-PY for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:34:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URPpF-0007ow-UV for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:30:48 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_MIME_NO_TEXT, T_TVD_MIME_NO_HEADERS autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:37831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URPpF-0007oq-CA for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:30:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URPpB-0007wv-Lp for bug-guile@gnu.org; Sun, 14 Apr 2013 12:30:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URPp9-0007nw-7r for bug-guile@gnu.org; Sun, 14 Apr 2013 12:30:41 -0400 Received: from li305-5.members.linode.com ([178.79.168.5]:41295 helo=cooksoni.karetnikov.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URPp9-0007ng-1m for bug-guile@gnu.org; Sun, 14 Apr 2013 12:30:39 -0400 From: Nikita Karetnikov Date: Sun, 14 Apr 2013 20:33:12 +0400 Message-ID: <87haj9ysvr.fsf@karetnikov.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) --=-=-= I think this example [1,2]: (define-syntax my-or (syntax-rules () ((my-or) #t) ((my-or exp) exp) ((my-or exp rest ...) (let ((t exp)) (if exp exp (my-or rest ...)))))) should look like this: (define-syntax my-or (syntax-rules () ((my-or) #t) ((my-or exp) exp) ((my-or exp rest ...) (let ((t exp)) (if t ; <- t (my-or rest ...)))))) Otherwise, what's the rationale behind 'let'? AFAICT, it's described here [3], but Guile is not affected, right? So the following works as well: (define-syntax my-or (syntax-rules () ((my-or) #t) ((my-or exp) exp) ((my-or exp rest ...) (if exp exp (my-or rest ...))))) Note that 'my-or' is used in several places (e.g., [4]) and it's necessary to change them all. Also, there are other macros that use 'let' (e.g., 'cond1'). [1] https://gnu.org/software/guile/manual/guile.html#Defining-Macros [2] https://gnu.org/software/guile/manual/guile.html#Hygiene [3] http://stackoverflow.com/a/3215238 [4] https://gnu.org/software/guile/manual/guile.html#Syntax-Case --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJRatpMAAoJEM+IQzI9IQ38xEEP+wYP5cZFgYMUkxFr9BFQD184 UiF1LoRoPbfM+brfeO5dEDUCXgdxZf5QWk57SU333sdHNMyx68R5358JPL3VGnq6 btphZlRCagWNBEBwW5rH5jjNsGi1ExRfx91+cRJ+Ab5ZyHzkVQ6F1gVcas71emqP K8Ur51B9PewIcpnhDYRqFphwNAHtypF+IOM5wyhlJaSnbwPHbacTzYHtI8k0SnbT lGRi1CKDy1uDMrrlelvUVgvS9SfUYzaL4TTxUoXOCuMlvjFQWadKdT/2a0utGXS0 Cokitr5sYnOJFR473NmwAOfccnV3CE6b+Fx2QO+hRSwVgBNlcODBsJNCbSVnxi2O ENBGVnCWzE4giNmiFxrRwmZc78GzVAJK/KzMv/ZFxlIfP0/L+t1dvvmjlQnSAFc4 7zK9xv+4fMwR2UchI99QtNn3cHkz4Q7BzDL0Rwxe0okofbkk2wVvGbK5CQiSfe1+ yX+DaS1wKiT5kkDYnaRmi05W/REzfQvhiXpDhqGvM76EttT4SFEYd43cUlw2Pyjx pxmdhd9qDdmceyfxYF3KXXVfGaCNaLfUGIz5gG9CudK//BTotym2Xq1rjVdwuqn/ gi+vK4yrU2ReQ3ezG/qnVs6WmcApvUqp0XmPvsZ/IXVZjG6ah/gFcuFw0M4H0nfu g8actXmVr2fqdO0saYuv =JEBL -----END PGP SIGNATURE----- --=-=-=-- From unknown Sun Jun 22 11:42:12 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Nikita Karetnikov Subject: bug#14203: closed (Re: bug#14203: Manual: 'my-or'; 'let' inside macros) Message-ID: References: <877gk53snx.fsf@tines.lan> <87haj9ysvr.fsf@karetnikov.org> X-Gnu-PR-Message: they-closed 14203 X-Gnu-PR-Package: guile Reply-To: 14203@debbugs.gnu.org Date: Sun, 14 Apr 2013 17:59:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1365962342-13543-1" This is a multi-part message in MIME format... ------------=_1365962342-13543-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14203: Manual: 'my-or'; 'let' inside macros which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14203@debbugs.gnu.org. --=20 14203: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14203 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1365962342-13543-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14203-done) by debbugs.gnu.org; 14 Apr 2013 17:58:03 +0000 Received: from localhost ([127.0.0.1]:50462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URRBi-0003TW-HC for submit@debbugs.gnu.org; Sun, 14 Apr 2013 13:58:03 -0400 Received: from world.peace.net ([96.39.62.75]:41347) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URRBg-0003T3-4m for 14203-done@debbugs.gnu.org; Sun, 14 Apr 2013 13:58:01 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1URR7a-0006s1-51; Sun, 14 Apr 2013 13:53:46 -0400 From: Mark H Weaver To: Nikita Karetnikov Subject: Re: bug#14203: Manual: 'my-or'; 'let' inside macros References: <87haj9ysvr.fsf@karetnikov.org> Date: Sun, 14 Apr 2013 13:53:38 -0400 In-Reply-To: <87haj9ysvr.fsf@karetnikov.org> (Nikita Karetnikov's message of "Sun, 14 Apr 2013 20:33:12 +0400") Message-ID: <877gk53snx.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 14203-done Cc: 14203-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Nikita Karetnikov writes: > I think this example [1,2]: > > (define-syntax my-or > (syntax-rules () > ((my-or) > #t) > ((my-or exp) > exp) > ((my-or exp rest ...) > (let ((t exp)) > (if exp > exp > (my-or rest ...)))))) > > should look like this: > > (define-syntax my-or > (syntax-rules () > ((my-or) > #t) > ((my-or exp) > exp) > ((my-or exp rest ...) > (let ((t exp)) > (if t ; <- > t > (my-or rest ...)))))) Indeed, thanks! I've pushed this fix to the stable-2.0 branch, and am closing this bug. Answers to your other questions follow. > AFAICT, it's described here [3], but Guile is not affected, right? > [3] http://stackoverflow.com/a/3215238 That post gives an example that looks superficially similar, but is actually entirely different: (define remove! (let ((null? null?) (cdr cdr) (eq? eq?)) (lambda ... function that uses null?, cdr, eq? ...) Indeed, this is not necessary in Guile due to its module system. > So the following works as well: > > (define-syntax my-or > (syntax-rules () > ((my-or) > #t) > ((my-or exp) > exp) > ((my-or exp rest ...) > (if exp > exp > (my-or rest ...))))) The above definition has a problem: it would result in 'exp' being evaluated more than once, unless it returns false. For example, if you used your proposed definition above, (my-or (read) 5) would expand to: (if (read) (read) 5) Which would obviously not do what you expect from 'or'. Instead, we want: (let ((t (read))) (if t t 5)) > Note that 'my-or' is used in several places (e.g., [4]) and it's > necessary to change them all. > [4] https://gnu.org/software/guile/manual/guile.html#Syntax-Case Unless I'm mistaken, the Syntax-case section uses 'my-or', but does not define it, so I don't think anything needs to be fixed there. Right? Thanks, Mark ------------=_1365962342-13543-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Apr 2013 16:34:58 +0000 Received: from localhost ([127.0.0.1]:50374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URPtK-0008O6-1Q for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:34:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57217) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URPtH-0008Nz-PY for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:34:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URPpF-0007ow-UV for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:30:48 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_MIME_NO_TEXT, T_TVD_MIME_NO_HEADERS autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:37831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URPpF-0007oq-CA for submit@debbugs.gnu.org; Sun, 14 Apr 2013 12:30:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URPpB-0007wv-Lp for bug-guile@gnu.org; Sun, 14 Apr 2013 12:30:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URPp9-0007nw-7r for bug-guile@gnu.org; Sun, 14 Apr 2013 12:30:41 -0400 Received: from li305-5.members.linode.com ([178.79.168.5]:41295 helo=cooksoni.karetnikov.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URPp9-0007ng-1m for bug-guile@gnu.org; Sun, 14 Apr 2013 12:30:39 -0400 From: Nikita Karetnikov To: bug-guile@gnu.org Subject: Manual: 'my-or'; 'let' inside macros Date: Sun, 14 Apr 2013 20:33:12 +0400 Message-ID: <87haj9ysvr.fsf@karetnikov.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) --=-=-= I think this example [1,2]: (define-syntax my-or (syntax-rules () ((my-or) #t) ((my-or exp) exp) ((my-or exp rest ...) (let ((t exp)) (if exp exp (my-or rest ...)))))) should look like this: (define-syntax my-or (syntax-rules () ((my-or) #t) ((my-or exp) exp) ((my-or exp rest ...) (let ((t exp)) (if t ; <- t (my-or rest ...)))))) Otherwise, what's the rationale behind 'let'? AFAICT, it's described here [3], but Guile is not affected, right? So the following works as well: (define-syntax my-or (syntax-rules () ((my-or) #t) ((my-or exp) exp) ((my-or exp rest ...) (if exp exp (my-or rest ...))))) Note that 'my-or' is used in several places (e.g., [4]) and it's necessary to change them all. Also, there are other macros that use 'let' (e.g., 'cond1'). [1] https://gnu.org/software/guile/manual/guile.html#Defining-Macros [2] https://gnu.org/software/guile/manual/guile.html#Hygiene [3] http://stackoverflow.com/a/3215238 [4] https://gnu.org/software/guile/manual/guile.html#Syntax-Case --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJRatpMAAoJEM+IQzI9IQ38xEEP+wYP5cZFgYMUkxFr9BFQD184 UiF1LoRoPbfM+brfeO5dEDUCXgdxZf5QWk57SU333sdHNMyx68R5358JPL3VGnq6 btphZlRCagWNBEBwW5rH5jjNsGi1ExRfx91+cRJ+Ab5ZyHzkVQ6F1gVcas71emqP K8Ur51B9PewIcpnhDYRqFphwNAHtypF+IOM5wyhlJaSnbwPHbacTzYHtI8k0SnbT lGRi1CKDy1uDMrrlelvUVgvS9SfUYzaL4TTxUoXOCuMlvjFQWadKdT/2a0utGXS0 Cokitr5sYnOJFR473NmwAOfccnV3CE6b+Fx2QO+hRSwVgBNlcODBsJNCbSVnxi2O ENBGVnCWzE4giNmiFxrRwmZc78GzVAJK/KzMv/ZFxlIfP0/L+t1dvvmjlQnSAFc4 7zK9xv+4fMwR2UchI99QtNn3cHkz4Q7BzDL0Rwxe0okofbkk2wVvGbK5CQiSfe1+ yX+DaS1wKiT5kkDYnaRmi05W/REzfQvhiXpDhqGvM76EttT4SFEYd43cUlw2Pyjx pxmdhd9qDdmceyfxYF3KXXVfGaCNaLfUGIz5gG9CudK//BTotym2Xq1rjVdwuqn/ gi+vK4yrU2ReQ3ezG/qnVs6WmcApvUqp0XmPvsZ/IXVZjG6ah/gFcuFw0M4H0nfu g8actXmVr2fqdO0saYuv =JEBL -----END PGP SIGNATURE----- --=-=-=-- ------------=_1365962342-13543-1--