(defmacro nif [expr pos zer neg]
'(condp = (Integer/signum ~expr)
-1 ~neg
0 ~zer
1 ~pos))
Je reçois cette erreur.Quel est le problème avec cette macro dans Clojure?
1:1 user=> #<Namespace Chapter7Macros>
1:2 Chapter7Macros=> (nif 1 (+ 2 2) (- 2 2) (- 3 2))
1:3 Chapter7Macros=> java.lang.Exception: Unable to resolve symbol: expr in this context (repl-1:57)
La police pour On Lisp rend difficile (pour moi, et apparemment aussi pour OP) de dire 'from \ '. En général, lorsque vous travaillez avec des macros que vous voulez \ '. (backtick, au cas où quelqu'un a des problèmes avec ma police!) – amalloy