Comment

Comment by sjamaan

Each procedure gets called with an extra argument, which is the continuation. That continuation is simply another closure which accepts a single argument, the return value of the procedure.

At the toplevel, the compiled code has a C function for every toplevel expression, and these functions just wrap up the "next toplevel expression" as the continuation that gets passed to the compiled C function that "executes" this expression. The final expression in the toplevel gets handed a special continuation which is the "implicit exit handler".

Inside procedures, we do something similar, but we keep the continuation we got from the toplevel and keep passing that along, creating new continuations as needed for the expressions inside.

parent sjamaan 25 days ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton