What are all of clojure's special forms?

828 views Asked by At

As part of improving Cider's debugger, I need to implement special handling for all possible special-forms. In order words, I need to know all symbols which satisfy special-symbol?. The doc page on Special Forms, while helpful, doesn't offer all of them.

For instance, after some experimentation, I've learned that

  1. Most of the forms listed there have a * counterpart (let* and loop*, for instance).
  2. There is a clojure.core/import* special-symbol (which I wouldn't have found if not for sheer luck).

Is there a complete list of all special symbols?
Alternatively, is there a way to list all interned symbols? If so, then I could filter over special-symbol?.

1

There are 1 answers

1
Charles Duffy On BEST ANSWER

Looking at the definition of special-symbol? provides a big clue:

(defn special-symbol?
  "Returns true if s names a special form"
  {:added "1.0"
   :static true}
  [s]
    (contains? (. clojure.lang.Compiler specials) s))

Thus:

user=> (pprint (keys (. clojure.lang.Compiler specials)))
(&
 monitor-exit
 case*
 try
 reify*
 finally
 loop*
 do
 letfn*
 if
 clojure.core/import*
 new
 deftype*
 let*
 fn*
 recur
 set!
 .
 var
 quote
 catch
 throw
 monitor-enter
 def)