This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (5)
- # aws (5)
- # aws-lambda (6)
- # babashka (6)
- # beginners (48)
- # calva (54)
- # clj-commons (12)
- # clj-kondo (39)
- # cljfx (3)
- # cljs-dev (11)
- # clojure (91)
- # clojure-europe (25)
- # clojure-uk (3)
- # clojurescript (16)
- # cursive (2)
- # data-oriented-programming (6)
- # datomic (8)
- # emacs (10)
- # events (3)
- # fulcro (2)
- # functionalprogramming (2)
- # graalvm (4)
- # graphql (2)
- # helix (1)
- # honeysql (4)
- # jobs (1)
- # malli (4)
- # nextjournal (21)
- # off-topic (5)
- # other-languages (4)
- # overtone (3)
- # reitit (17)
- # releases (2)
- # rewrite-clj (6)
- # ring (6)
- # shadow-cljs (37)
I just started to use Clerk, even without thinking a lot about the "output" in the browser. It is very useful to just press "Ctrl-c c" (clerk/show! ) after any code change anywhere in my clojure file, and just knowing that clerk will do the right thing and evaluate exactly what needs to be evaluated. (and do it immediately, because all is cached in-memory) I do not need to think myself "which forms" to evaluate after a code change. I would even call this a new paradigm to work with Clojure apart from "repl first" and "clj-file first" 🙂
This is super useful in any situation where evaluation of forms takes more then a second, so a blind "eval buffer" would be too slow. With Clerk we get a kind of "eval buffer", but it will only eval what is strictly needed , so what has changed and the dependencies of the changed forms. It avoids the need to actively decide which forms to evaluate after a change.
As forms in Clerk notebooks can be out of order, this can result in "notebooks" which are not "valid" clojure files, "valid" in the sense of failing to be running via
I would not call this being an "issue", but just a consequence of the way Clerk works.
I can have a valid notebook, where defs are out of order:
(def a (+ b 1) (def b 2)
Clerk evaluates and renders it, as it detect the order of dependencies.
Running the same as
clj xx.clj will fail.
That's why clerk does not support redefining of defs... But we can detect this and fail on it. https://github.com/nextjournal/clerk/pull/92
So that why Clerk is really a "different way" to render a "file full of Clojure forms"
But ok, the forms above you can as well render in Cider doing the correct order by hand. So Clerk just automates this....
"valid" Clerk notebooks are not guaranteed to work via
So they are not guaranteed to be valid namespace definitions.
Which is perfectly fine for "top level" files which are never required.
(this is different in notespace). An notespace file is always a valid namespace
actually, clerk won’t eval this either:
(ns fw) (def a (+ b 1)) (def b 2)
validate.clj: 28 clojure.tools.analyzer.passes.jvm.validate/eval2917/fn MultiFn.java: 229 clojure.lang.MultiFn/invoke validate.clj: 265 clojure.tools.analyzer.passes.jvm.validate/validate validate.clj: 240 clojure.tools.analyzer.passes.jvm.validate/validate Var.java: 384 clojure.lang.Var/invoke passes.clj: 166 clojure.tools.analyzer.passes/compile-passes/fn/fn passes.clj: 168 clojure.tools.analyzer.passes/compile-passes/fn/fn passes.clj: 168 clojure.tools.analyzer.passes/compile-passes/fn/fn passes.clj: 168 clojure.tools.analyzer.passes/compile-passes/fn/fn core.clj: 2635 clojure.core/partial/fn …
But it would work after JVM restart, which in normal Clojure does not. (via
But I agree that a 2 times (`cider-eval-buffer`) can make it work as well.
So not a big deal.
But I would somehow like to be sure that my Clerk notebooks can be run via
clj from the command line.
@carsten.behring that still requires Clerk to be on the Java classpath, right? Otherwise no extra setup?
I've used an alias to add clerk as an optional dependency and then I launch my REPL using that alias for when I want to have clerk available at dev time without introducing a strict dependency on it.