On Thu Sep 25, 2025 at 10:43 PM CEST, Rolando Abarca via Chicken-users wrote:
> Hello,
>
> I've encountered an interesting behavior with Chicken's module system that
> I'd like to understand better. When a module has a completely empty export
> list, any exports generated by macros within the module body seem to be
> ignored.
>
> Here's a minimal example that demonstrates the issue:
>
>   ;; mylib.scm
>   (module mylib () ;; Empty export list
>
>   (import scheme chicken.base chicken.syntax)
>
>   (define-syntax define-with-export
>     (er-macro-transformer
>       (lambda (x r c)
>         (let ((name (cadr x))
>               (value (caddr x)))
>           `(,(r 'begin)
>              (,(r 'export) ,name)
>              (,(r 'define) ,name ,value))))))
>
>   (define-with-export foo "hello")
>   )
>
> When compiling with csc -s -J mylib.scm and trying to use it:
> (import mylib)
> foo ;; Error: unbound variable
>
> However, if I change the module to export at least one symbol directly:
> (module mylib (dummy) ;; Non-empty export list
> ;; ... rest of code including a (define dummy 'x)
>
> Then the macro-generated export of foo works as expected.
>

Hm... I'm trying to reproduce this and csc complains about "export"
requring "chicken.module" (not "chicken.syntax"). With the import
changed to "chicken.module", the macro seems to work ok.

Is the example given above correct?


cheers,
felix


Reply via email to