GNU bug report logs - #65132
[PATCH] fix cond1 macro

Previous Next

Package: guile;

Reported by: Ekaitz Zarraga <ekaitz <at> elenq.tech>

Date: Mon, 7 Aug 2023 18:28:01 UTC

Severity: normal

Tags: patch

Done: lloda <lloda <at> sarc.name>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Timothy Sample <samplet <at> ngyro.com>
To: Ekaitz Zarraga <ekaitz <at> elenq.tech>
Cc: 65132 <at> debbugs.gnu.org
Subject: bug#65132: [PATCH] fix cond1 macro
Date: Mon, 07 Aug 2023 14:15:47 -0600
Hi all,

Ekaitz Zarraga <ekaitz <at> elenq.tech> writes:

> From ab6e4980ea301b5d1e14a98464e5de3e726984f1 Mon Sep 17 00:00:00 2001
> From: Ekaitz Zarraga <ekaitz <at> elenq.tech>
> Date: Mon, 7 Aug 2023 20:23:42 +0200
> Subject: [PATCH] fix cond1 macro

Just adding some context, as we talked about this on IRC.

If you take the docs example as is,

    (define-syntax cond1
      (syntax-rules (=> else)
        ((cond1 test => fun)
         (let ((exp test))
           (if exp (fun exp) #f)))
        ((cond1 test exp exp* ...)
         (if test (begin exp exp* ...)))
        ((cond1 else exp exp* ...)
         (begin exp exp* ...))))

and invoke it as

    (cond1 else #t)

you get

    Syntax error:
    unknown location: else: bad use of 'else' syntactic keyword in
    subform else of else

This is because ‘else’ matches the ‘(cond1 test exp exp* ...)’ pattern
and gets inserted as the test:

    (if else (begin #t))

This patch puts the more specific ‘else’ pattern before the more general
‘test’ pattern so it has a chance to be matched.


-- Tim




This bug report was last modified 1 year and 231 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.