From unknown Sun Jun 22 07:30:29 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#14203 <14203@debbugs.gnu.org> To: bug#14203 <14203@debbugs.gnu.org> Subject: Status: Manual: 'my-or'; 'let' inside macros Reply-To: bug#14203 <14203@debbugs.gnu.org> Date: Sun, 22 Jun 2025 14:30:29 +0000 retitle 14203 Manual: 'my-or'; 'let' inside macros reassign 14203 guile submitter 14203 Nikita Karetnikov severity 14203 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 14 12:34:58 2013 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----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 14 13:58:03 2013 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 From unknown Sun Jun 22 07:30:29 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 13 May 2013 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator