Summary

module-environment use with macros

Metadata

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

[2023-11-10 14:48:03 UTC] sjamaan changed status from new to closed

[2023-11-10 14:48:03 UTC] sjamaan set resolution to fixed

[2023-11-10 14:48:17 UTC] sjamaan changed milestone from 6.0.0 to 5.4