[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Having trouble with syntax-source
From: |
Mitchell Kember |
Subject: |
Having trouble with syntax-source |
Date: |
Fri, 22 Apr 2022 12:51:27 -0400 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Having trouble with syntax-source,
Mitchell Kember <=