I was dipping my toes into Go development last week for work, and one of the neat things about `go fmt` enforcing a single formatting style (besides avoiding bikesheds) is that it makes it possible for tooling to automate code changes without reformatting the code

It got me wondering if something like that might be useful for Lisps. Especially since I've also been thinking about structural editors for s-expression langs recently which would run into the same problem

...since a structural editor working on a Lisp program would essentially be reading the program in from the source, working with it in tree form, then serializing it back out as text. If you can't do that round-trip without losing the formatting (and comments? gotta figure that one out) it'd be more annoying to work with

Would take away some formatting customizability but it'd add to Lisp's metaprogramming superpowers too, I think

Follow

@jfred I treat all whitespace as nodes in my ASTs and just gloss it over when I stitch stuff into the tree but I use them to serialize back into text. With whatever formatting is there

@mauve Oh cool! I remember seeing something like that with ruamel.yaml in python. Are you doing that with lisps or other languages?

@jfred I wrote a bespoke parser and AST transformer thing for SAS (statistical analysis lang used in pharma). Sadly all proprietary. 😅

I wanna get into it for more langs though. I find a lot of parser ecosystems don't put enough effort into making it easy to serialize back to text after parsing + transforming 😅

Sign in to participate in the conversation
Mauvestodon

Escape ship from centralized social media run by Mauve.