Rationale
I'm writing a type checker for Clojure code that utilizes a modified version ClojureScript analyzer.
I have made some changes to the analyzer to analyze Clojure code, instead of ClojureScript.
These changes could form the basis of a generalized analyze library to be called a la carte.
Thoughts
- The ClojureScript compiler could use this more general library
- Should keep in mind ClojureScript's usage
Differences running the analyzer on Clojure code
(In progress)
Differences in 'ns syntax
- Unqualified :use and :require are legal in Clojure
- :use/require-macros don't exist in Clojure
Resolving macro expanders
- Should look for macro expanders in :use and :require instead of :use-macros and :require-macros
Keeping metadata on fn args
Something I found helpful for annotating types. Possibly alternative strategy
Remove namespace substitution of 'cljs.core from 'clojure.core
- All vars that resolve to clojure.core have their namespace substituted for cljs.core
- (def ^:dynamic *subst-clojure-core-ns* 'clojure.core)
Analyzer doesn't understand macros (defmacro's)
- The analyzer doesn't define a new macro when parsing/analyzing a defmacro form
- This doesn't matter with CLJS code, can't define new macros.
- Can in Clojure code though.
- This doesn't matter with CLJS code, can't define new macros.
Initial Namespacing Environment
- Should be clojure.core and clojure.user, instead of cljs.core/user
Munging js-reserved symbols
- Special case not applicable to Clojure
Namespace/name separator in symbols referring to vars
- `resolve-var` returns a symbol with (str ns "." name)
- Clojure uses (str ns "/" name) for vars, and (str ns "." name) for classes
- Why does this happen in CLJS?
- Clojure uses (str ns "/" name) for vars, and (str ns "." name) for classes
Labels: