Code
(defn sprintf [& args]
(with-out-str
(apply printf args)
*out*))
Error
(Chrome)
Uncaught TypeError: Cannot read property 'cljs$lang$maxFixedArity' of undefined
Question:
What am I doing wrong?
The error:
Uncaught TypeError: Cannot read property 'cljs$lang$maxFixedArity' of undefined
...perhaps history's most baffling error message, actually means:
You're calling
applyon a function that doesn't exist (or hasn't been required).
Rock on, future Googlers!
(def sprintf format) seems easier.
undefined as if it were a function.I don't get the error you saw, I get an error "No *print-fn* fn set for evaluation environment".
If you dig through the source at https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs you'll find this message in the docs for *print-fn* :
"Each runtime environment provides a diffenent way to print output. Whatever function *print-fn* is bound to will be passed any Strings which should be printed."
So I suggest you play around with *print-fn* - or as @amalloy suggested, just use 'format' directly.
(incidentally if you look at https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure it indicates "*out* is currently not implemented".)