Really cute Clojure project that builds a full parse tree (i.e including whitespace), allows code to transform the _abstract_ syntax tree, then splices the changed sexp whilst preserving source comments! https://vimeo.com/45695419
Enables code transformations that look like macros.
miniblog.
Related Posts
C# has an interesting concept of second-class macros called Source Generators: https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/
You can generate additional code at build time, but you can't transform existing expressions (unlike normal macros), so it's more amenable to tooling.
Do compilers ever transform pairs of malloc/free? E.g. in a loop:
p = malloc(32);
foo(p);
free(p);
In principle this doesn't need to be allocated on the heap.
I'm rewriting a Rust function transform function from `&mut Foo` to `Foo -> Foo`. It might be a little slower, but ownership makes it harder to miss parts of the Foo type when I work with values.
