What are the rules for resolving characters like macros and function parameters?

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 fragments to rate to 5).

What is the rule for character resolution in shading and macros, as well as special forms?

I am using the version on Try Clojure .

+5
source share
2 answers

It is not possible to hide special forms, according to the documentation :

Symbol allowed:

  • , var, . , var, , var .
  • , Java, . , .
  • ** , :
    • , . **
    • , , . , Java. , , . '' .
    • ( ) , , (, let-bound name). , .
    • , , var. , var, .
    • .

, ( ), , :

- , , . , var, , . .

, .

+6

5 (Clojure 1.4 Eclipse/ REPL). , Try Clojure, 3.

, ( , !).

, def . / Clojure, .

+3

All Articles