Fork me on GitHub

Hey, folks! I'm taking a look at rewrite-clj from a perspective of a tool that allows to have Clojure programs as data, as I'm curious about this idea and about an interface to manage such data that would allow to complement my beloved emacs. 🙂 rewrite-clj can read a Clojure program and gives zipper and pareddit interface - that's a nice start!


I'm curious, can a whole Clojure program with all its Clojure dependencies be read as data?


E.g., read Clojure program as data, fetch its Clojure dependencies, repeat


Sure, why not, as long as you implement fetching the deps etc. yourself: any Clojure program as string can be read with rewrite-clj


What problem would your tool solve? There may already be tools out there that could help you


I'm curious about it because text-based management of today relies on names (places) to link together a program. E.g., code is given a name some-ns/some-def and anybody who wants code refers to its name, that resolves to code at last at run-time. Lately I've taken look at UnisonWeb, they have program as an immutable structure with names as user-level entities, allowing to label parts of that immutable structure to make sense of it as one sees fit (they have personal dictionaries of content = label , so one person can label code of reduce as foldl , another as Map - it's a personal view of data). I'm curious to have a similar approach for Clojure programs. For that, it seems to me, we could read program as data and decompose code from labels (names). If anybody's curious about reasoning on this problem, But it's size is way out of hand. 😄


Are there any tools that could be building blocks for such a solution?


There are static analysis tools like clj-kondo which can retrieve data from pieces of clojure code. It's based on rewrite-clj.


There is also tools.analyzer which can return an AST as EDN from Clojure programs.


> There is also tools.analyzer which can return an AST as EDN from Clojure programs. That sounds interesting, I'll take a look. Thanks. 🙂


Editor tooling like clojure-lsp is built on the clj-kondo analysis. Depending on what you want that may be already enough


clj-kondo seems to derive semantical information out of syntactic information rewrite-clj provides, that'll be of use!