Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut to use the last-ep-id in letsc #45

Open
jprudent opened this issue Jul 5, 2022 · 0 comments
Open

Shortcut to use the last-ep-id in letsc #45

jprudent opened this issue Jul 5, 2022 · 0 comments

Comments

@jprudent
Copy link

jprudent commented Jul 5, 2022

Hello !

Because most of the time I'm interested in the last spy, I found that I can inject this macro in my user NS, to avoid having to find the ep-id manually
(and because we can't do (sc.api/letsc (sc.api/last-ep-id) x) )

(defmacro letsc
  [& body]
  (let [ep-id (sc.api/last-ep-id)]
    `(sc.api/letsc ~ep-id ~@body)))

I use it like this

(defn foo [x] (sc.api/spy x))
SPY <-20> /tmp/form-init17184007261798462834.clj:1 
 At Code Site -20, will save scope with locals [x]
=> #'user/foo
(foo 12)
SPY [91 -20] /tmp/form-init17184007261798462834.clj:1 
  At Execution Point 91 of Code Site -20, saved scope with locals [x]
SPY [91 -20] /tmp/form-init17184007261798462834.clj:1 
x
=>
12
=> 12
(letsc x)
=> 12

It's really a nice improvement I think, so I would like to share it with you in case you also think so.

Thanks for scope capture, I love it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant