Please use the scope-capture library instead.
This library eases REPL-based development, by providing macros which help you save and restore the local environment of a piece of code with minimal effort.
Project status: still alpha, expect changes etc. On the other hand, you typically will only use it in your development environment.
This library is designed to support the programming / debugging methodology advocated by Stuart Halloway in this blog post: REPL Debugging: No Stacktrace Required, which consists of:
- recreating the environment in which a piece of code runs (using
def
s) - evaluating forms in the code buffer to narrow down the cause of the problem
What the blog post does not mention is that oftentimes, this first step (recreating the local environment) can get very tedious and error-prone; especially when the values of the environment are difficult to fabricate (HTTP requests, database connecitons, etc.), which can be the case for online programs such as web servers, or if you don't have a keen knowledge of the project.
This library alleviates this pain by:
- providing macros that let you save snapshots of the local environment on the fly:
bf.code/spy
(which additionally saves the evaluated wrapped expression - or the resulting error, which you can inspect usingbf.code/saved-value
) andbf.code/brk
(which acts as a breakpoint, blocking the flow of the program until you choose to release it from the REPL usingbf.code/loose!
, possibly with a value which supersedes the evaluation of the wrapped expression usingbf.code/loose-with!
orbf.code/loose-with-ex!
) - providing macros that let you restore these snapshots from the REPL:
bf.code/defsc
(recreates the environment with global vars, i.e bydef
-ing the local names) andbf.code/letsc
(recreates the environment with locals, i.e bylet
-ing the local names)
- Demo video
- Usage documentation
- disable / enable code sites
- clojure.main/repl sub-repl
- experiment with ClojureScript
Copyright © 2016 Valentin Waeselynck and contributors.
Distributed under the MIT license.