2 ms·
Hmmm. I think this is yet another example of how the various programming communities have difficulty talking with each other. This "continuation passing style"
by dragontamer 6y ago
Hmmm. I think this is yet another example of how the various programming communities have difficulty talking with each other.
This "continuation passing style" with a Decent Compiler™ has been well known to the C++ community, to the point where the C++ community commonly exclaims that sort() is faster than qsort().
sort() is a template function, which means that the compiler will generate a "new sort" each time you pass in an argument. And much care has been put forth to ensure that the parameter function can easily be inlined by the compiler.
Not quite 100%: sort() is a simple function and not a proper continuation. But still, I've seen C++ inline lambdas before.
-----------
Of course, in the Lisp / Functional land, its all called "Continuation passing style". C# may call it async style. Javascript may call it callbacks.
-----------
It should also be noted that compiler theory also calls things "continuation passing style" (in contrast to Single Static Assignment). Compilers need to "normalize" the code into a certain form (SSA: where all variables have ONE assignment max is probably more popular today. But Continuation Passing Style is proven to be an equivalent, and alternative, means of normalizing).
I clicked expecting SSA vs Continuation Passing Style. Turns out its the "other" continuation passing style being discussed here.