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.
miniblog.
Related Posts
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.
It's amazing that merging work at all.
It's a dumb textual transform that provides no guarantees that the code is even syntactically valid, let alone correct. The problem feels AI-complete.
I've seen bad resolutions of merge conflicts way more than bad automatic merges though.
