Summary
module-environment use with macros
Metadata
- Id: 44e36fedb079625928146445dfd4ccddd4f479a1
- Trac id: 1295
- Type: defect
- Reporter: caolan
- Owner:
- Cc:
- Status: closed
- Component: core libraries
- Estimated difficulty: hard
- Resolution: fixed
- Priority: major
- Milestone: 5.4
- Version: 4.11.0
- Changetime: 2023-11-10 14:48:17 UTC
- Created: 2016-06-07 12:21:23 UTC
- Keywords:
Description
Given the following module example.scm:
(module example *
(import chicken scheme)
(define (add a b) (+ a b))
(define-syntax double
(syntax-rules ()
((_ x) (add x x))))
)
Then, using it as an eval environment:
(load "./example.scm") (import example) (print (eval '(double 10) (module-environment 'example)))
I get:
Error: unbound variable: add43
Using the macro directly it appears to work:
(load "./example.scm") (import example) (print (double 10))
It now prints 20, as expected.
Is this a problem with module-environment, or am I using it incorrectly?
Changes and comments
[2016-08-25 20:44:00 UTC] sjamaan set difficulty to hard
[2016-08-25 20:44:18 UTC] sjamaan wrote:
This looks like a bug, but I'll have to look closer when I have more time
[2017-03-27 21:53:52 UTC] caolan wrote:
Just in case anyone else runs into this issue, I'm working around it by using er-macro-transformer instead of syntax-rules:
(define-syntax double
(er-macro-transformer
(lambda (exp rename compare)
(list (rename 'add) (cadr exp) (cadr exp)))))
[2023-11-06 23:48:36 UTC] felix changed milestone from someday to 6.0.0
[2023-11-10 14:47:58 UTC] sjamaan wrote:
Fixed with fe4e2db7b36c46028f9dadcda19010d1f684c406