Interesting. No warning in Clojure. But same happens with Planck:
$ planck
ClojureScript 1.10.520
cljs.user=> (ns foo.bar (:require [clojure.string :as str]))
nil
foo.bar=> str/upper-case
#object[Function]
foo.bar=> (ns foo.bar)
nil
foo.bar=> str/upper-case
^
WARNING: No such namespace: str, could not locate str.cljs, str.cljc, or JavaScript source providing "str" at line 1
WARNING: Use of undeclared Var str/upper-case at line 1
Execution error (ReferenceError) at (<cljs repl>:1).
Can't find variable: str
@sogaiu ^
@grav thanks for the data point! i heard this doesn't occur for shadow-cljs.
Okay ... maybe it's something with self-hosted?
Anyway, I'm normally using in-ns
for these things (this is what Cursive also uses). Eg:
cljs.user=> (ns foo.bar (:require [clojure.string :as str]))
nil
foo.bar=> (ns baz.buz)
nil
baz.buz=> (in-ns 'foo.bar)
foo.bar=> str/upper-case
#object[Function]
foo.bar=>
the background is that at #chlorine we're working on trying to figure out stuff we can send to a variety of repls -- the following was working for non-clojurescript repls:
(if (find-ns 'foo.bar) (in-ns 'foo.bar) (ns foo.bar))
thanks for the info on what cursive uses -- does cursive work with self-hosted repls? i haven't tried.
I have used it together with lumo actually. Lumo exposes a socket repl, and when I used Cursive, it didn't support it directly. But then I launched (via Cursive) a clojrue program that used Mike Fikes' socket repl client https://github.com/mfikes/tubular for connecting.
I think Cursive will soon support socket repls directly though. Maybe already does 🙂
yes, i've heard of tubular -- cool that those can be connected.
thanks for the tips 🙂
gotta go to sleep now
🙂 Np - sleep tight! 🙂
take care!