I was playing around with an idea for a code generator for a language we'll call "platypus" by defining an s-expression syntax for it, something like c-amplify
I defined (in the "platypus" package) some expansion macros with names like "class" and "function" that happen to be symbols in CL. For convenience, I'd like the user to be able to use these tokens "unadorned" by introducing the new syntax by wrapping it in a form like so:
Code: Select all
(platypus
;; Introduces new syntax & symbol table
(class blah ...
... etc... ))
Code: Select all
(defmacro platypus (&body body)
`(let ((*package* (find-package :platypus)))
,@body))
Then next best I could do was:
Code: Select all
(defmacro platypus (&body body)
`(macrolet ((class (&body body)
`(platypus:class ,@body)))
,@body))
Is there a better approach to this? Am I looking at the problem in the wrong way?