I am trying to use macro with two forms in LISP, which evaluates both forms but always return the result of form 2. Below is the code that I am using -
(defmacro testmac (x body) (prog2 x body))
When executing the macro with following forms, It works correctly and always return 5 which is the second form.
(testmac (- 10 6) (/ 10 2))
However when I try to execute macro with following forms, its return error.
(testmac (print a) (print b))
Below is the error I get -
debugger invoked on a UNBOUND-VARIABLE: The variable B is unbound.
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(SB-INT:SIMPLE-EVAL-IN-LEXENV B #<NULL-LEXENV>)
Why am I getting this error and how can I use macro to make this work?
P.S. I cannot use defun need to use macro to execute (testmac (print a) (print b))