* Having trouble with syntax-source
@ 2022-04-22 16:51 Mitchell Kember
0 siblings, 0 replies; only message in thread
From: Mitchell Kember @ 2022-04-22 16:51 UTC (permalink / raw)
To: guile-user
Hi,
I'm having trouble using syntax-source in a macro.
Here's what I have:
#!r6rs
(import (rnrs (6)))
(define-syntax foo
(lambda (x)
(syntax-case x ()
((_ e)
(begin
(display (syntax-source #'e))
(newline)
#'(display (syntax-source #'e)))))))
(foo (list 1))
Displaying the syntax-source works the first time during macro
expansion, but not the second time in the result of the macro:
$ guile --no-auto-compile --r6rs test-0-guile.ss
((filename . test-0-guile.ss) (line . 13) (column . 5))
Backtrace:
2 (primitive-load "/path/to/test-0-guile.ss")
In ice-9/eval.scm:
191:35 1 (_ #f)
In unknown file:
0 (syntax-source (#<syntax list> #<syntax 1>))
ERROR: In procedure syntax-source:
In procedure syntax-source: Wrong type argument in position 1
(expecting syntax object): (#<syntax list> #<syntax 1>)
I've tried the same thing in Racket and Chez Scheme and it works fine there:
https://gist.github.com/mk12/dc5a54107e46e67d702bb377304b144f
Is there some way to fix it for Guile? (Ideally in a way that also
works for Racket and Chez, since I'm in a codebase that targets all of
them, https://github.com/mk12/sicp).
Thanks,
Mitchell
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-22 16:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 16:51 Having trouble with syntax-source Mitchell Kember
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).