Re:Flattening ASTs (and Other Compiler Data Structures)
by rurban on Saturday January 11, 2025 @10:52AM
(#42666649)
I worked in a language where all datastructures were "flattened", could be trivially serialized to disk, and read in again. Called print and read. The language was called lisp. All flat, just parens.
Some of my compilers export the AST as lisp trees. Much smaller and more readable than json, and it can be executed. Uniform like bricks
Re:Flattening ASTs (and Other Compiler Data Structures)
by vanderZwan on Saturday January 11, 2025 @01:36PM
(#42667948)
> All flat, just parens.
So not flat then. Prefix is not postfix. Forth, and most concatenative languages, are much closer to actually bein, flat.
Lisp is trivial to flatten, but that's not the same thing.
https://github.com/gritzko/librdx/blob/master/abc/B.md
Apart from locality and lifetimes, these flat data structures improve composability. When every data structure is a flat buffer, you can mmap them or zip them or send them by the network, all by the same routine. They are uniform like bricks, in a sense.