Continuation Passing Style


Abbreviated as CPS, this is a technique of a stackless implementation of function call. This basically works by, instead of pushing a new frame to the stack before any subroutine execution, replacing the entire context by a new continuation, that in the end will route to some place else. The "return" concept is a little modified here, because we don't have to simply drop a frame of the stack, but when we want to simulate the standard stack behaviour, the current subroutine should know where it should return to when it finishes.

This feature is used in SMOP to support different interpreter implementations in the same run loop.