That's actually not too bad... I might try just installing 0.1.7 and then putting my inspect selection command in that way, as an experiment. I'd certainly rather run with the "stock" Chlorine so it's easier for me to customize on both machines without having to run from source.
@mauricio.szabo You showed JS above for your "init script" -- is that something different to init.coffee
?
Figured it out...
Inspect Selection in REBL!
I cannot get go to var definition to work in 0.1.7...
Show source doesn't seem to work either.
On a brighter note, I've sort of got the bug for defining new commands in my init file now 🙂 Inspect current namespace. Inspect var at cursor. Define var/expr (so you can turn parts of a let
into top-level def
s to make it easier to debug and eval sub-expressions. I ❤️ REBL.
how do I stop my defonce
definitions from being overwritten when I reload a file? 😕
I'll look at these two bugs right now. There shouldn't be any breakages, but we never know... after all, the current new code is registering commands in a different manner
@michael.e.loughlin, what command are you using? If it's the full refresh, I use clojure.tools.namespace to do the refreshing part, and the approach they use is to drop the full namespace and then reload everything
yeah, full refresh. would you recommend simple? I don't remember why I chose full, so it can't have been an important decision
You chose full because it is the default 😄. But I'll change these defaults on the next version too. Try to change it to "simple" and see if it works - probably will. It's not really that easy to configure a project to use a kind of refresh that clojure.tools.namespace expects...
I'll give it a go when I'm at my workstation, thanks!
When you try "goto definition", are you getting an Atom error?
yep that fixed it
I can avoid using integrant for a little bit longer now my top-level defonces are back 😄
Just found the problem: on newer versions of ClojureScript, clojure.core/let
resolves to cljs.core/let
instead of keeping the original namespace.
I was using it as a "poor man's template engine", seems like it's time to rethink it 🙂
(and cover these parts with tests too :D)
FWIW, I never use any automated refresh process in all project.
Eric Normand's REPL-Driven Development course (which is excellent, BTW, and well worth the money!) also advises against the auto-refresh stuff, and instead advocates a better REPL workflow where you develop practices that let you avoid that stuff.
Interesting. I've been using my own "inspect var" instead since that lets me see the source code in REBL which is mostly what I use go to var definition for.
~ cljs
ClojureScript 1.10.520
cljs.user=> `let
cljs.core/let
cljs.user=> `clojure.core/let
cljs.core/let ;;; <==
I think that this behavior is a bugi believe that's intended? because clojure.core
doesn't actually exist in CLJS
everything is implemented in cljs.core
however, to help with cross-platform macros etc. the CLJS compiler will rewrite references to clojure.core
as cljs.core
this way you can write macros like this:
(defmacro foo []
`(let [a# 1 b# 2]
(+ a# b#))
and it will work in Clojure or ClojureScript.
instead of having to somehow detect in the macro if you're being run as part of the CLJS compiler and fully-quality all the core functions/macros like:
(cljs.core/let [a# 1 b#]
(cljs.core/+ a# b#)
thanks for the recommendation Sean. How do you go about updating your REPL with the most up-to-date defn
and such?
you don't have to answer if it gives too much of Eric's course away 😂
I hit ctl-, b
or ctl-, B
depending on whether I want to eval the current form or the top-level form. ctl-, f
if I want to (re-)load the whole file. Those are the three "eval" steps that Eric talks about in the course. The "practice" is to develop the habit of always taking small steps: edit a form, eval it, edit a form, eval it, etc.
that makes a lot of sense
I often work across multiple files without even needing to save them. Edit a function, ctl-, B
, write a test expression, ctl-, b
, rinse, repeat. Occasionally I save and then ctl-, f
to reload a file (which doesn't overwrite defonce
BTW).
I will try out disabling the namespace reload stuff 🙂
it seems like a small jump from how Chlorine encourages users to (comment (...))
eval forms
Rich Comment Forms 🙂
Yeah, I've been using those for ages at work, as does my teammate. It was funny to watch Stu's talk about RDD and hear him recommend the same thing -- and call them Rich Comment Forms (because Rich does that too).
I write C# for my day job, and I find comment
takes over the documentation role of unit tests, and you can put them in the same file as your business logic - like Rust tests. I really like it. Only Lisp! 🙂