Re: Can (export ...) be used reliably from inside a macro expansion?
Rolando Abarca via Chicken-users <[email protected]>
| Newsgroups | gmane.lisp.scheme.chicken |
|---|---|
| Message-ID | <CADnrc4CmQ29MhK6sUi+JM1tKFmQNYG13kR1hya9oL_r42NK0sQ@mail.gmail.com> |
That did the trick! ha... I should read the docs better. Thanks Peter! Best, On Sat, Aug 23, 2025 at 4:42 AM Peter Bex via Chicken-users < [email protected]> wrote: > On Fri, Aug 22, 2025 at 09:51:20AM -0700, Rolando Abarca via Chicken-users > wrote: > > So my question is: is it possible in CHICKEN to dynamically generate > export > > declarations from inside a macro expansion, or is the module system > > designed in such a way that the export list must be known before macro > > expansion? > > This should work. I struggled a bit myself before realizing that the > documentation says an export should always *precede* its definition. > Maybe you missed that too. > > For instance, this works: > > (module foo () > (import scheme (chicken module)) > > (define-syntax define&export > (syntax-rules () > ((_ ?name ?value) > (begin (export ?name) > (define ?name ?value))))) > > (define&export x 1)) > > (import foo) > (print x) > > Hope this helps! > > Cheers, > Peter > >