Question

I would like to forward-declare a function in ClojureScript. Kind of

(defn a [] (b))
...
(defn b [] ...)

I think what kind of works is to place a (def b nil) in front of the usage (b) but I wonder if there is a "better" way.

Was it helpful?

Solution

It seems that declare does the trick. I only found documentation on it for Clojure but it seems to work in ClojureScript as well.

http://clojuredocs.org/clojure_core/clojure.core/declare

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top