Can (export ...) be used reliably from inside a macro expansion?
Rolando Abarca via Chicken-users <[email protected]>
| Newsgroups | gmane.lisp.scheme.chicken |
|---|---|
| Message-ID | <CADnrc4A+qrz_tULTv-P5mnKwd3qej-_J9r6eu0MnNzB+P_T4Wg@mail.gmail.com> |
Hi all, I’m experimenting with a macro that defines some record types and also generates the corresponding accessors. Ideally, the macro would also export those generated bindings automatically, so that the module user doesn’t have to list them manually. I tried having the macro expand into forms like: (export user-id user-name user-fields) When I check with (expand ...), the macro expansion looks correct. But when I compile the module, the compiler complains that the symbols I’m trying to export are "not defined." If I change the module header to use * (export all top-level bindings), then everything compiles and works fine: the generated accessors are available to client code. 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? If the latter, is the recommended approach just to use * and then hide what I don’t want, or to generate the module header programmatically? My thought here was to put the macro in a different module and use it in a place where I know I want all the top-level defs to be exported. Thanks for any guidance! - Rolando