vvvvalvalval / scope-capture

Project your Clojure(Script) REPL into the same context as your code when it ran
MIT License
576 stars 14 forks source link

Trouble with cljs #17

Closed chpill closed 6 years ago

chpill commented 6 years ago

Hi val!

I've been trying to use this library (finally!), but I've encountered some issues with clojurescript. The page on the pitfalls of cljs repls states that using the REPL provided by figwheel should be okay. Unfortunately I could not get it to work. I've set up a minimal case to show the issue I encountered here https://github.com/chpill/cljs-sc-test.

TL;DR I end up having those seemingly contradictory results at the REPL:

dev:cljs.user=> (require '[sc.api :as sc])
nil
dev:cljs.user=> (sc/ep-info 1)
#:sc.ep{:id 1,
        :code-site
        #:sc.cs{:id -1,
                :expr (+ a b c),
                :local-names [x a b c],
                :dynamic-var-names nil,
                :file
                "/home/chpill/p/clj/buf/cljs-sc-test/script/cljs-vanilla-repl.clj",
                :line 10,
                :column 5},
        :local-bindings {x 4, a 8, b 12, c 16},
        :dynamic-var-bindings {}, 
        :value 36}
dev:cljs.user=> (sc/letsc 1 a)
----  Could not Analyze  <cljs form>   line:1  column:1  ----

  No Execution Point with ID 1

  1  (sc/letsc 1 a)
     ^--- 

----  Analysis Error  ----
nil

Any idea what might be going wrong?

vvvvalvalval commented 6 years ago

Hi @chpill, maybe I'm not making it apparent enough, but in ClojureScript you need to write (sc.api/letsc [1 -1] ...) instead of just (sc.api/letsc 1 ...), see this section in the tutorial: https://github.com/vvvvalvalval/scope-capture/blob/master/doc/Tutorial.md#usage-from-clojurescript

Can you tell me if this solves your issue?

chpill commented 6 years ago

It does indeed, thanks for the clarification!

So, are the warnings during the cljs compilations normal?

vvvvalvalval commented 6 years ago

@chpill I wouldn't call the warnings normal, rather they're a (somewhat harmless) artifact of my poor mastery of CLJC.

vvvvalvalval commented 6 years ago

@chpill opened a new issue about the warnings https://github.com/vvvvalvalval/scope-capture/issues/18, and closing this one.

If you want to give it a shot ;)