Skip to content

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

@jprudent

Description

@jprudent

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions