What are the rules for resolving symbols as macros vs. function parameters?

Viewed 235

I was surprised to find that alpha-conversion is not safe in Clojure:

Clojure> ((fn [o] (o 3 2)) +)
5

Clojure> ((fn [or] (or 3 2)) +)
3

Clojure> ((fn [def] (def 3 2)) +)
java.lang.RuntimeException: First argument to def must be a Symbol

(I expected all three snippets to evaluate to 5).

What's the rule(s) for symbol resolution when shadowing and macros, and special forms are involved?

I'm using the version on Try Clojure.

2 Answers
Related