This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (4)
- # aws (3)
- # babashka (58)
- # beginners (59)
- # biff (6)
- # cider (3)
- # clj-kondo (48)
- # clj-on-windows (1)
- # cljdoc (1)
- # clojure (136)
- # clojure-europe (19)
- # clojure-gamedev (7)
- # clojure-germany (2)
- # clojure-nl (7)
- # clojure-norway (1)
- # clojure-portugal (1)
- # clojure-uk (4)
- # clojurescript (41)
- # community-development (2)
- # core-async (5)
- # cursive (10)
- # data-oriented-programming (1)
- # data-science (1)
- # datahike (5)
- # datomic (58)
- # docker (2)
- # emacs (13)
- # figwheel-main (19)
- # fulcro (12)
- # graalvm (9)
- # holy-lambda (41)
- # honeysql (14)
- # introduce-yourself (3)
- # jobs (4)
- # lsp (11)
- # nrepl (1)
- # off-topic (9)
- # other-languages (2)
- # pathom (22)
- # portal (5)
- # re-frame (17)
- # remote-jobs (4)
- # reveal (14)
- # shadow-cljs (1)
- # tools-build (7)
- # tools-deps (47)
- # xtdb (8)
- # yada (2)
im thinking about a better REPL flow for awhile.
here is what i came up with so far:
1. use special REPL files for establishing and working with various contexts of a bigger application, eg. one file per 3rd-party API, database, http layer, etc
2. most REPL files are probably development only and contain destructive operations, which is don't want to execute accidentally in a production Clojure process, so they should live under a directory, eg.
<project-root>/dev/, so they are not deployed to production.
3. we should use file-based evaluation, NOT buffer-based, by default, so we can't accidentally load such code through a production REPL
4. the namespaces for these REPL files should be shallow, in case we need to type their names out manually. eg.
project.name.datomic-repl (which would reside in
x.y.datomic-repl.clj naming scheme - as opposed to
x.y.datomic.repl.clj - helps to distinguish multiple REPL files being open in various editors, which might chop off, abbreviate or display with a pale color the
6. we should use rich-comments in such REPL files, so we can just reload them any time without side-effects.
and here is the workflow part (position of the caret shown as •):
1. start with this:
(comment (-> *1•) )
*1is highlighted. we edit this form:
then eval it and i'd expect a copy of the evaluated form appear above the form itself and my cursor stay in place:
(comment (-> some-seq (doto pprint) (->> (map :some/key•) (keep :other/key))) )
so i can keep iterating on the form, while maintaining a history of its evolution, which i can clean up later. i'd also expect the undo operation to remove the copied form, in case im just repeating the same operation for its side-effect. eg. maybe im just polling something manually.
(comment (-> some-seq (doto pprint) (->> (map :some/key) (keep :other/key))) (-> some-seq (doto pprint) (->> (map :some/key•) (keep :other/key))) )
Somewhat related, one thing I’ve thought of recently which I think would be really useful, similar to https://github.com/cursive-ide/cursive/issues/2623. I’d like a command to be able to execute a rich-comment form from anywhere in the file. So probably a command which pops up a searchable list of all the comment-commands in the current file, and allows me to execute them.
other useful approach which has emerged in my usage is this form:
so i can see the result of the computation, while also capturing it
(comment @(def some-var *1) @(def some-var (-> (some computation) (print-summary))) )
@U0567Q30W yes, that bookmarked evaluation is also a great building block, i've just realized in the last 2-3days.
i often need to modify some function definition in an NS and re-run a form in another NS, to test out the effect of my change.
so far im just using the
Re-execute last command option of a Cursive
REPL Command, but the last action gets overwritten, when I execute another Cursive
A while back I used a "save command" repl command that saved the text of your current editor selection and your current ns. Was able to run that code again in the future from any context. It's super useful, and it'd be nice to have some more official support for something like that
Cursive doesn't provide that, but there's another plugin on top of Cursive that does: see #clj-extras-plugin