1
votes

What do &form and &env do in this example (taken from core.clj)?

(def
  ^{:macro true
    :added "1.0"}
  let (fn* let [&form &env & decl] (cons 'let* decl)))

Do symbols beginning with &... (other than just plain &) have special meaning in any contexts?

Why aren't &form and &env used in the body of the fn* form?

1
Perhaps this link would be helpful. blog.jayfields.com/2011/02/clojure-and.html - ntalbs

1 Answers

3
votes

Yes, &form and &env are special variables within a macro. The names begin with '&' to avoid name clashes with normal user-defined symbols.

The value of &form is the form of the original macro call before macro expansion.

The value of &env is a map of lexical bindings. The keys of &env are the lexically bound symbols.

[adapted from stevenminer's comment]