ProductPromotion
Logo

Clojure

made by https://0x3d.site

GitHub - GeorgeJahad/debug-repl: Clojure REPL that is aware of surrounding lexical scope
Clojure REPL that is aware of surrounding lexical scope - GeorgeJahad/debug-repl
Visit Site

GitHub - GeorgeJahad/debug-repl: Clojure REPL that is aware of surrounding lexical scope

GitHub - GeorgeJahad/debug-repl: Clojure REPL that is aware of surrounding lexical scope

The Clojure debug-repl

Every time I stick a println into some Clojure code to debug it, I think to myself, "This is Lisp! I should be able to insert a repl here!"

The problem is of course that Clojure's eval function doesn't know about the surrounding lexical scope. How to solve the problem? Create a macro that passes a copy of the lexical scope in with the form to be evaled, something like this:

(defn eval-with-locals [locals form] (eval `(let ~(generate-local-bindings locals) ~form)))

USE: The interface is meant to be dead simple: "(use 'alex-and-georges.debug-repl)" loads it, and "(debug-repl)" invokes it.

That's about it. When you enter the debug-repl, the regular repl prompt will be replaced with

dr =>

An example will make it clearer:

user=> (let [c 1 d 2] (defn a [b c] (debug-repl) d)) #'user/a

user=> (a "foo" "bar")

dr-1-1001 => c "bar"

dr-1-1001 => d 2

dr-1-1001 => locals {fn__104 #<user$eval__103 user$eval__103@5f6303>, c "bar", d 2, fn__106 #<user$eval__103$a__105 user$eval__103$a__105@179dce4>, b "foo", counter__56__auto__ 1001}

dr-1-1001 => (str b c) "foobar"

dr-1-1001 => () 2 user=>

LIMITATIONS: The debug-repl doesn't currently integrate properly with the slime-repl, (I think because of how Slime manages IO redirection,) so you'll have to invoke it from a regular repl, or slime's inferior lisp buffer.

A version of the debug-repl has been ported to slime. More details here: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory