Hey I'd like SCI to resolve undefined symbols to nil instead of throwing "Could not resolve symbol: x". Is there a natural way to do this?
Yeah, I think that's fine for now :^)
what's your use case for this feature btw?
I've created a web app for creating and editing hiccup templates such that changes to the templates are reflected immediately in the app using the templates. Change a color in the template and the color immediately changes in the app.
Since this updates on every keystroke I often times get into invalid states and I don't want the app to flash every time that happens. Therefore I'm using some heuristics to handle the most common such cases. One such common case I've found, is accessing unbound symbols.
I'm using parmezan for this also, so that I can actually see the results while in the middle of typing e.g [:div [:span "foo .
Thank you for parmezan 馃!
:-D
This here (sorry for two clips, screen recording is a bit crashy for me)
nice. is this in a JS environment?
you could use codemirror + clojure-mode for automatic paren matching
This is an Electric Clojure app so both JVM and JS :^)
I guess it doesn't show in the clips I sent but left and right side run in different browser tabs
I'll take a look at codemirror and clojure-mode 馃
this playground uses it for example: https://babashka.org/sci.configs/
waaaaaaa
that's awesome
I'll definitely use that!
Me and Claude landed on this which works for me :^)
;; Patch SCI so undefined symbols resolve to nil instead of throwing
(defn- resolve-symbol-lenient
([ctx sym] (resolve-symbol-lenient ctx sym false nil))
([ctx sym call?] (resolve-symbol-lenient ctx sym call? nil))
([ctx sym call? m]
(second
(or (sci-resolve/resolve-symbol* ctx sym call? m)
[nil nil]))))
#?(:clj (alter-var-root #'sci-resolve/resolve-symbol (constantly resolve-symbol-lenient))
:cljs (set! sci-resolve/resolve-symbol resolve-symbol-lenient))Thanks for the great library!
Be aware that changing something in a namespace called .impl may change at any time