Re: Macro-generated exports not working with empty module export list

Felix Winkelmann via Chicken-users <[email protected]>
Newsgroups gmane.lisp.scheme.chicken
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.