by zenhack · 7y ago · 0 comments
In languages like rust/c/c++, this might be hard, since you can't grow the stack by moving them (since you'd need to update pointers, which are too visible in those languages, and even identifying a pointer at runtime is undecidable), and segmented stacks cause the "hot-split" problem.
But most languages could just make this problem go away by growing the call stack when needed. A few of them (incl. Haskell) do. I'm following suit in a language I'm working on.
If you want the gory details https://www.microsoft.com/en-us/research/wp-content/uploads/...
In another HN thread there is much discussion about Rust using, in effect, segmented stacks to implement async-await.
Perhaps you could code a recursive descent parser in Rust using async functions, so that the Rust compiler converts it to a heap-allocated state machine for you.