scope-capture icon indicating copy to clipboard operation
scope-capture copied to clipboard

Document internals

Open vvvvalvalval opened this issue 8 years ago • 4 comments
trafficstars

The reader should understand:

  • what information is created and accessed by what processes, and where it's stored.
  • how spy / letsc / defsc work

vvvvalvalval avatar Oct 18 '17 01:10 vvvvalvalval

Hi @vvvvalvalval , could you add some details? Clojure 'reader' or the user? Any way I could help out?

divs1210 avatar Jan 18 '18 17:01 divs1210

Clojure 'reader' or the user?

The user of the library.

I am actually not sure this documentation section is still needed, because I filed this issue before creating the 'Pitfalls' section in the README: https://github.com/vvvvalvalval/scope-capture/wiki/Pitfalls-with-(browser-connected)-ClojureScript-REPLs.

@divs1210 One way you could help is to tell me how documentation could be improved. What parts of scope-capture, its value prop, its usage or its internal, seem unclear or dubious to you?

vvvvalvalval avatar Jan 21 '18 16:01 vvvvalvalval

@vvvvalvalval As a user of this awesome lib, I'd like to understand the internals of the spy macro: What parts of Clojure do you use in order to be able to get the list of all the bindings, including destructured bindings etc...?

viebel avatar Aug 18 '19 06:08 viebel

Hey @viebel, I should document this indeed, thanks.

The list of in-scope locals is actually provided by the Clojure compiler: macros can read it in a value bound to a 'magical' &env local. In scope-capture, this value gets passed to helper functions under the name amp-env.

Unfortunately, the schema of &env varies depending on whether you're compiling with Clojure JVM or ClojureScript, which incurs a penalty in complexity to make scope-capture cross-platform. See here: https://github.com/vvvvalvalval/scope-capture/blob/897978eae42d1e5dfe88f582cc81473014b42b85/src/sc/impl.cljc#L131.

vvvvalvalval avatar Sep 09 '19 08:09 vvvvalvalval