2 ms·
The modern/popular way is to run a format tool before you commit. (gofmt, clang-format, etc) A VCS for syntax trees means you need the One True Data Format(tm)
by qznc 11y ago
The modern/popular way is to run a format tool before you commit. (gofmt, clang-format, etc)
A VCS for syntax trees means you need the One True Data Format(tm) for syntax trees in any language. Finding consensus on formatting per project is easier than unifying all syntax tree representations globally.
- WorldMaker 11y agoAdditionally, there are many reasons you might want to commit work in progress code that doesn't/won't parse correctly to a "proper" syntax tree. While there are certainly workarounds (pseudo-trees for "malformed"/"unfinished" sections), there's entire neighborhoods of bikesheds to paint there. (Amongst the major compilers thus far the only ones I've seen invest useful time in mostly unified intermediate syntax trees is the Roslyn compilers for C#/VB, often compilers don't care but Roslyn had the opportunity/drive/interest to try to merge a lot of editor support directly into the compiler infrastructure.) (Aside: I built a cool proof of concept for what I think is the most useful "smart middle ground" here, which is to use syntax highlighting lexers (tokenizers) for a useful effect in creating smart character-based diffs. Syntax highlighting lexers are designed for intermediate code and with output as ordinary character diffs you don't have to bikeshed a universal token stream format. The tokenized diffs were cleaner and faster than the equivalent non-tokenized character diff. https://github.com/WorldMaker/tokdiff https://github.com/WorldMaker/tokdiff if anyone wants to play with it.)