This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-14
Channels
- # adventofcode (14)
- # announcements (3)
- # babashka (18)
- # beginners (32)
- # calva (1)
- # clj-kondo (65)
- # cljs-dev (5)
- # cljsrn (3)
- # clojure (22)
- # clojure-spec (13)
- # clojure-uk (53)
- # clojured (3)
- # clojuredesign-podcast (50)
- # clojurescript (8)
- # core-async (32)
- # cursive (15)
- # data-science (1)
- # datomic (17)
- # fulcro (48)
- # hyperfiddle (1)
- # off-topic (5)
- # shadow-cljs (2)
- # testing (2)
i'm trying to replicate some version of george jahad's debug repl -- here is a simplified version by technomancy: https://github.com/technomancy/limit-break/blob/master/src/limit/break.clj
@sogaiu there is a REPL function here: https://github.com/borkdude/babashka/blob/dce1029c2789f1225eefc5aa1eee4d71c3db3e38/src/babashka/impl/clojure/main.clj#L59 and here it is invoked: https://github.com/borkdude/babashka/blob/dce1029c2789f1225eefc5aa1eee4d71c3db3e38/src/babashka/impl/repl.clj#L13 But maybe we could also expose the first one to babashka itself, right now it's not
Nice:
$ clj
Clojure 1.10.1
user=> (clojure.main/repl)
user=> (+ 1 2 3)
6
user=> nil ;; exit inner REPL with ^D
user=> ^D ;; exit outer REPL with ^D
@borkdude thanks! here is my first unsuccessful attempt: https://github.com/borkdude/babashka/pull/155
Good start. One reason why it doesn't work is because in sci clojure.core/*in*
is bound to a sci var, whereas in your function it's bound to the real clojure.core/*in*
probably
not understanding very well...trying to piece things together: in babashka's main.clj, there is:
[(start-repl! ctx #(read-next *in*)) 0]
and
(defn start-repl! [ctx read-next]
(let [ctx (update ctx :bindings assoc
(with-meta '*in*
{:sci/deref! true})
(read-next))]
(repl/start-repl! ctx)))
and
read-next (fn [*in*]
(if (pipe-signal-received?)
::EOF
(if stream?
(if shell-in (or (read-line) ::EOF)
(read-edn))
(delay (cond shell-in
(shell-seq *in*)
edn-in
(edn-seq *in*)
:else
(edn/read *in*))))))
so the *in*
being used at bb's repl is not the vanilla *in*
. is that along the lines of your hint?yes, although later I realized I might have not said the right thing, but it's worth digging deeper
the repl function you are passing is now running with the default options, that might be why it doesn't work
i took an unclean approach to see if i could get things working. i exposed: * ctx that babashka.main/start-repl! sets up as @main/gctx * babashka.impl.repl/start-repl! function as main/start-repl! then did this:
$ lein bb
Babashka v0.0.42-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (main/start-repl! @main/gctx)
Babashka v0.0.42-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> :hi
:hi
user=> :repl/quit
nil
user=>
so may be that gives some hints about what to do