@borkdude: Looks like the tests have all passed on my PR: https://github.com/borkdude/sci/pull/424 I think this is roughly what you meant, but let me know if you want me to make any more changes
Looks good!
Maybe add a check for qualified symbol?
user=> (find-var '+)
Execution error (IllegalArgumentException) at user/eval1 (REPL:1).
Symbol must be namespace-qualified
Also:
user=> (find-var 'foo/bar)
Execution error (IllegalArgumentException) at user/eval143 (REPL:1).
No such namespace: foo
:thumbsup:
The constructor bug has also been fixed on bb master
ahh amazing!
Hi it seems I can stop asking questions... Is there a Clojurescipt equivalent to:
(sci/binding [sci/out *out*]
(sci/eval-string "(println \"something\")"))
In other word can I bind something to make println
work when using sci from Clojurescript? Do I need to use console.log
?Very good question. I think xterm-sci is currently the best example, but I think it might be better for the future of sci started supporting *print-fn*
for CLJS.
https://github.com/babashka/xterm-sci/blob/main/src/xterm_sci/core.cljs
https://babashka.org/xterm-sci/
But you can also just re-bind println
directly using the :namespaces
option
depending on what you want to do
I'll take a look at the example thanks! I'll also the rebinding option, didn't think of that one!
If I get it right the sci internal 'clojure.core/println
is bound to cljs.core/println
that's neat. I'll try that!
yup
Thanks it works for my case.
@borkdude: I’ve updated: https://github.com/borkdude/sci/pull/424 With some error handling to mimic clojure’s behaviour, let me know if you require any further tweaks.
Excellent. Merged. Also updated bb master:
$ lein bb "(find-var 'clojure.string/join)"
#'clojure.string/join
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (master) $ lein bb "(find-var 'clojure.string/joinz)"
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (master) $ lein bb "(find-var 'clojure.stringx/joinz)"
----- Error --------------------------------------------------------------------
Type: java.lang.IllegalArgumentException
Message: No such namespace: clojure.stringx
Location: <expr>:1:1
----- Context ------------------------------------------------------------------
1: (find-var 'clojure.stringx/joinz)
^--- No such namespace: clojure.stringx
----- Stack trace --------------------------------------------------------------
user - <expr>:1:1
Error encountered performing task 'run' with profile(s): 'test'
Suppressed exit
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (master) $ lein bb "(find-var 'clojure)"
----- Error --------------------------------------------------------------------
Type: java.lang.IllegalArgumentException
Message: Not a qualified symbol: clojure
Location: <expr>:1:1
----- Context ------------------------------------------------------------------
1: (find-var 'clojure)
^--- Not a qualified symbol: clojure
----- Stack trace --------------------------------------------------------------
user - <expr>:1:1
Error encountered performing task 'run' with profile(s): 'test'
Suppressed exit
Amazing, thank you!