Hacker News new | ask | show | jobs
by anyfoo 567 days ago
If you want to have "fun", generate code in a WASM-representation of Hoare's WHILE language, i.e. a program that only consists of a single outer while loop (in WASM a "loop" block), and conditionally decide for every single instruction in the loop whether it should be executed during a given pass.

I think that could be done with a single-pass C compiler. In a very trivial (and terrible) case, you could keep a running "line_counter" variable that every statement in the loop is predicated with, which either gets incremented at the end of the loop, or set to an arbitrary value for representing branches.

It would of course be a horrible (but very amusing) mess, and rather enforces your actual point.

1 comments

Reminds me of what I understand from the „Usagi Electric“ Bendix rotating drum -memory-computer execution :)