* bug#65132: [PATCH] fix cond1 macro
@ 2023-08-07 18:27 Ekaitz Zarraga
2023-08-07 20:15 ` Timothy Sample
2023-09-29 17:02 ` bug#65132: lloda
0 siblings, 2 replies; 3+ messages in thread
From: Ekaitz Zarraga @ 2023-08-07 18:27 UTC (permalink / raw)
To: 65132
From ab6e4980ea301b5d1e14a98464e5de3e726984f1 Mon Sep 17 00:00:00 2001
From: Ekaitz Zarraga <ekaitz@elenq.tech>
Date: Mon, 7 Aug 2023 20:23:42 +0200
Subject: [PATCH] fix cond1 macro
* doc/ref/api-macros.texi (Macros): Fix doc1 macro example
---
doc/ref/api-macros.texi | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/ref/api-macros.texi b/doc/ref/api-macros.texi
index 7fdf578c7..f13ac0136 100644
--- a/doc/ref/api-macros.texi
+++ b/doc/ref/api-macros.texi
@@ -229,10 +229,10 @@ Literals are used to match specific datums in an expression, like the use of
((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* ...))))
+ (begin exp exp* ...))
+ ((cond1 test exp exp* ...)
+ (if test (begin exp exp* ...)))))
(define (square x) (* x x))
(cond1 10 => square)
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#65132: [PATCH] fix cond1 macro
2023-08-07 18:27 bug#65132: [PATCH] fix cond1 macro Ekaitz Zarraga
@ 2023-08-07 20:15 ` Timothy Sample
2023-09-29 17:02 ` bug#65132: lloda
1 sibling, 0 replies; 3+ messages in thread
From: Timothy Sample @ 2023-08-07 20:15 UTC (permalink / raw)
To: Ekaitz Zarraga; +Cc: 65132
Hi all,
Ekaitz Zarraga <ekaitz@elenq.tech> writes:
> From ab6e4980ea301b5d1e14a98464e5de3e726984f1 Mon Sep 17 00:00:00 2001
> From: Ekaitz Zarraga <ekaitz@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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#65132: ...
2023-08-07 18:27 bug#65132: [PATCH] fix cond1 macro Ekaitz Zarraga
2023-08-07 20:15 ` Timothy Sample
@ 2023-09-29 17:02 ` lloda
1 sibling, 0 replies; 3+ messages in thread
From: lloda @ 2023-09-29 17:02 UTC (permalink / raw)
To: 65132-done
Patch applied in 1e3b5390e3c24e66013118e9751db4de5025a4a2.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-29 17:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-07 18:27 bug#65132: [PATCH] fix cond1 macro Ekaitz Zarraga
2023-08-07 20:15 ` Timothy Sample
2023-09-29 17:02 ` bug#65132: lloda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).