Lazy/infinite seqs: When I write (def foo (iterate #(mapv inc %) (vec (range 100)))) with something like (take 3 foo) and evaluate the notebook, at first everything works fine. However, when I change the definition of foo (say, change 100 to 80), it loads forever and eventually crashes (not always, but on most re-evaluations), even though I have ^{::clerk/visibility {:result :hide}} set on the definition to prevent realizing the lazy seq.
Of course, evaluating the form in Clojure is fast and causes no issues, because the lazy seq doesn’t get realized and the vector argument is bound to 100 items. Weirdly, I get no problems with Clerk when I change it to (iterate #(map inc %) (range 100)) or even (iterate #(identity %) (vec (range 80))), so it seems to have something to do with the mapv transformation.
Any idea why it behaves like that? Does Clerk just ignore the definition when I hide the result and set ::clerk/no-cache true or does it still do some processing on the form/result?
[Update]: It seems like presenting the def with v/var-viewer solves the problem, since this only renders the var name, not (parts of) the actual value.
Thanks - setting nextjournal.clerk.config/*bounded-count-limit* to 0 seems to work, although I’m not sure I understand what it does.
hi peter, clerk does a bounded-count on a sequence, the default limit is currently one million (been meaning to lower it) and you can set it via the JVM system property clerk.bounded-count-limit or bind nextjournal.clerk.config/*bounded-count-limit*
BTW: is it possible to run clerk using clojureScript?
Not yet. There is an example somewhere on how to use the CLJS compiler with macros on the JVM to evaluate CLJS code though (Matt Huebert has done one, perhaps @sritchie09 too). Don't remember which one it was off the top of my head. But maybe in the future clerk will support CLJS directly, just not there yet.
here it is! https://clerk-utils.mentat.org/#show-cljs-macro
here’s a notebook showing it off, it’s a touch involved to set it up https://clerk-utils.mentat.org/dev/clerk_utils/show.html
How do you mean? Like, run the whole notebook in the browser? If so, consider Maria as a possible choice.