Search code examples
packagelispcommon-lispasdf

How to correctly import a macro from a user defined package?


I'm trying to import a macro defined in a utility package, but when I try to use the macro I get a message that says that debugger invoked on a UNDEFINED-FUNCTION my-macro and that my-package:my-macro is a macro, not a function. However when I call functions defined inside that same package I got no errors.


Solution

  • Macro expansion happens at compile time. Your message indicates that the file that uses the macro was compiled when the macro was not defined, so the compiler assumed that the unknown name my-macro names a function (if you look at the compilation logs, you should see a message to that effect).

    Solution: require the file containing macro definitions in files that use them.