clojureでは、マクロはプログラマに大きな力を与えます。 eval
も非常に強力です。両者には微妙な違いがあります。私は、この謎がこの話題を明るく照らしてくれることを願っています。 1は、例外が発生し、なぜ他のものにはないrun-stuff
体、内部に3文以上Clojure riddle:eval、macros、およびnamespace
(ns hello)
(defmacro my-eval [x] `~(read-string x))
(defn hello[] "Hello")
(defn run-stuff []
(println (hello))
(println (my-eval "(hello)"))
(println (eval (read-string "(hello)"))))
(ns main)
(try (hello/run-stuff)
(catch Exception e (println e)))
?
私はこの美しい質問Clojure - (read-string String calling functionの調査に続いて、次のような謎を定式化しました。説明のための@Matthias Benkardのおかげで、