Post #2420319
2026-05-09 15:17 UTC
@joe@f.duriansoftware.com I went back and looked at the Metaware docs you posted. I'm somewhat impressed by how many problems are solved by just using their "CPS transform with nested functions" approach. The problem with doing straightforward shallow generators is that it's a pain to get recursive traversals of data structures, but it falls out naturally from their approach.
What I'm still unclear about is the natural compiler IR for representing/optimizing such a language.
Replies (1)
-
@joe@f.duriansoftware.com 2026-05-09 16:23
@zwarich@hachyderm.io had you seen https://arxiv.org/pdf/2604.09961 yet? mlir has their "region" thing which lets you stuff a whole sub-CFG with references to the outer context into an operand, similar to ideas for "subfunctions" we had for SIL. a late pass to split out invocation functions for closures that survive inlining/DCE/etc. seems reasonable for ultimately targeting LLVM or WASM. but if you do pascal style nested funcs with chained activation records, you could probably lower that representation directly