Writing a ++ macro in Common Lisp
common-lisp, lisp, macros
Solution
Remember that a macro returns an expression to be evaluated. In order to do this, you have to backquote:
(defmacro ++ (variable)
`(incf ,variable))
Problem
I've been attempting to write a Lisp macro that would perfom the equivalent of ++ in other programming languages for semantic reasons. I've attempted to do this in several different ways, but none of them seem to work, and all are accepted by the interpreter, so I don't know if I have the correct syntax or not. My idea of how this would be defined would be ``` (defmacro ++ (variable) (incf variable)) ``` but this gives me a SIMPLE-TYPE-ERROR when trying to use it. What would make it work?