Conversation

I think this is essentially "finally tagless": instead of defining your structures (AST or IR) as data, define them as classes; in the parser resp. elaborator, "construct" the AST resp. IR by calling methods; make instances do elaboration, resp. perhaps code generation, directly.
1
1
You can also define instances to construct an actual AST/IR as data, if you need that, for example to do analysis/optimization. (I'm not sure if you couldn't also do those as a directly fused chain, but I'm pretty sure you couldn't if you need to compute fixed points.)
2
1
There also might be downsides in terms of blowing out your instruction cache (or something like that) with too much fusion, which could reduce throughput I think? But yeah, it would be interesting to measure this.
2
You might inspire me to try this again though - I think it could be super fun to try, even with something like STLC. Would be cool if you could fuse ANF, closure conversion, SSA, etc all the way down.
1
1
The basic condition is that you can fuse something away if you use it linearly... I don't have enough compiler-writing experience to know offhand which passes satisfy that and which ones don't, so that's a fun question.
1
1
Replying to and
The other thing I'd like to try is pull-based compilation - but IIRC that might require better support for generators in Rust if I wanted to maintain my own sanity… here's something I was messing with ages ago:
Replying to
Oh hey this was the first idea I had too. :) twitter.com/glaebhoerl/sta I started to doubt whether it even made made sense after learning of the push-based "finally tagless" approach (and after not receiving a response there).
Quote Tweet
Replying to @pervognsen
Huh. I was thinking of trying to write a single-pass parser+typechecker with the TC in direct style, and the lexer+parser it pulls nodes from then state machines (but also written directly, as generators). This seems to be the other way around. Is either direction possible?
1
Show replies