This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-08
Channels
- # announcements (1)
- # beginners (21)
- # calva (27)
- # cljs-dev (25)
- # clojure (40)
- # clojure-europe (5)
- # clojure-italy (1)
- # clojure-uk (5)
- # clojurescript (9)
- # clojureverse-ops (1)
- # clojutre (1)
- # cursive (15)
- # datomic (9)
- # emacs (28)
- # fulcro (3)
- # jackdaw (5)
- # joker (3)
- # pedestal (1)
- # protorepl (6)
- # shadow-cljs (1)
- # spacemacs (3)
- # sql (1)
- # tools-deps (6)
- # vim (6)
- # yada (1)
A bit rusty here as I am working on the a cider issue Say I create a Rhino REPL with the instructions https://clojurescript.org/reference/repl
Is there a neat one liner to get the control back to the caller? Meaning, I want to inspect the env
, what should I do? Is running (repl/repl env)
in a future
an option?
Otherwise the repl input I am running on will get captured from the new Java process (it seems)
@richiardiandrea You can use :special-fns
as a repl option
they receive env
as a param when invoked: https://github.com/clojure/clojurescript/blob/b38ded99dc0967a48824d55ea644bee86b4eae5b/src/main/clojure/cljs/repl.cljc#L783-L788
You can do a lot w/ :special-fns
actually. It’s run on the client-side (i.e. w/ the compiler), so you can do all kinds of work there.
I cannot see the :special-fns
options in the repl?
You can see it takes it here: https://github.com/clojure/clojurescript/blob/b38ded99dc0967a48824d55ea644bee86b4eae5b/src/main/clojure/cljs/repl.cljc#L1062 And it uses it here: https://github.com/clojure/clojurescript/blob/b38ded99dc0967a48824d55ea644bee86b4eae5b/src/main/clojure/cljs/repl.cljc#L1115
sorry to beat this horse but I have finally tried 😄
user=> env
#cljs.repl.nashorn.NashornEnv{:engine #object[jdk.nashorn.api.scripting.NashornScriptEngine 0x77719e74 "jdk.nashorn.api.scripting.NashornScriptEngine@77719e74"], :debug nil, :special-fns {test-me #function[user/fn--6454]}}
user=> (cider.piggieback/cljs-repl env)
To quit, type: :cljs/quit
nil
cljs.user=> (test-me)
WARNING: Use of undeclared Var cljs.user/test-me at line 1 <cljs repl>
So I am still missing something it seems, maybe the special fn is a form, not a function object?no well, it is clj code after all ... I think I am still missing something
take a look here: https://github.com/potetm/tire-iron
it does (prn form)
😄
ok checking!
Ok I got it, I was passing the :special-fns
key to the nashorn env, not the inner cljs env
Oh ok, well, my problem is that the input is now listening for things for the Cljs repl instead, but I want to eval clj code
(that's why I thought I could exec that in a separate thread, but maybe I am on the wrong track here)
(my-special-fn (run-some-code))
where {'my-special-fn (fn[_ _ form] (prn (form)))}
might actually work?
you basically get full control in special fns — you can talk to the server, you can inspect the client env
Oh I see will try that, thanks!