Code diving macros
An experimental Clojure macro system implementing "code diving" macros: beyond traversing the wrapped code, they resolve called functions and macros, fetch their source, and recursively traverse it. All redefined fns/macros are accumulated in a let/macrolet binding, topologically sorted by call/dependency order, so instrumented code calls these local redefinitions that lexically shadow the global definitions.
What it addresses
Existing approaches for local monkey-patching in Clojure are problematic: with-redefs temporarily changes global definitions that other threads (including already existing ones) can see, and globally redefining targeted functions makes the modifications available to the whole program for the rest of its execution.
Shared over time
Each entry reflects what was shared on that date. Details may have changed since then.
Code diving macros
An experimental Clojure macro system implementing "code diving" macros: beyond traversing the wrapped code, they resolve called functions and macros, fetch their source, and recursively traverse it. All redefined fns/macros are accumulated in a let/macrolet binding, topologically sorted by call/dependency order, so instrumented code calls these local redefinitions that lexically shadow the global definitions.
Problem: Existing approaches for local monkey-patching in Clojure are problematic: with-redefs temporarily changes global definitions that other threads (including already existing ones) can see, and globally redefining targeted functions makes the modifications available to the whole program for the rest of its execution.
Audience: Programmers who need to locally patch or instrument existing code they don't control, such as code from another library.
Posted by @ValentinA23 · Original source ↗
Source text · @ValentinA23 · · Source ↗
What I'm working on is "code diving" macros. Not only will they traverse the passed code, but they will resolve called functions and macros, fetch their source code and traverse it too.