Pepe's Braindump

Continuation Passing Style

tags
Programming Languages

CPS

How does Kotlin rewrite direct style to CPS

https://www.youtube.com/watch?v=YrrUCSi72E8 Roman Elizarov descrives how they do implement the rewrite. Something unexpected for me is that they do it using a State Machine instead of doing it using callbacks, the reason being that with State Machines they do fewer allocations, since the same state machine is threaded through all the suspended functions.

Kotlin suspend

How does C# rewrite Async functions

They follow a similar technique to Kotlin (or the other way around… IDK who was inspired by who)

https://www.codeproject.com/Articles/535635/Async-Await-and-the-Generated-StateMachine

https://channel9.msdn.com/Events/Build/BUILD2011/TOOL-829T

Cortex theme by Jethro Kuan. Built with org-mode, org-roam and Hugo