You have a clash between "First" on the caller level and "First" inside a 'define-macro statement generated by 'macro.
You could put 'square-sum in its own namespace:
Code: Select all
(module "macro.lsp")
(context 'mymacros)
(macro (square-sum X Y)
(letn ((First X)
(Second Y)
(sum (+ First Second)))
(* sum sum)))
(context MAIN)
(let ((First 9)) (mymacros:square-sum 1 First)) => 100
Unfortunately a
default functor as used in one of the examples in
http://www.newlisp.org/downloads/newlis ... fine-macro will not work together with the macro.lsp module. UPDATE: a new macro.lsp, now online, also allows
default functors.
On a general note:
Use expansion macros generated using the macro.lsp only for small one-liners. The function/fexpr call overhead saved when using macro.lsp is not worth it with any code longer than a line.
Almost always using 'define-macro with 'letex or 'evel is the better choice.
Fexprs generated with 'define-macro work well as context
default functions and load faster when newLISP is reading source.