What is the difference between defn and defmacro?

后端 未结 5 1392
青春惊慌失措
青春惊慌失措 2021-02-01 02:25

What is the difference between defn and defmacro? What is the difference between a function and a macro?

5条回答
  •  悲&欢浪女
    2021-02-01 03:24

    The Other answers cover this well in depth so I'll try to cover it as succinctly as I can. I would appreciate edits/comments on how to write it more succinctly while keeping it clear:

    • a function transforms values into other values.
      (reduce + (map inc [1 2 3])) => 9

    • a macro transforms code into other code.
      (-> x a b c) => (c (b (a x))))

提交回复
热议问题