And I mean that in the same sense that a C/Java for
is just a funky syntax for a while
loop.
I still remember when first learning about the for
loop in C, the mental effort that had to go into understanding the execution sequence of the three control expressions relative to the loop statement. Seems to me the same sort of effort has to be applied to understand Continuations (in Scala and I guess probably other languages).
And then there's the obvious follow-up question... if so, then what's the point? It seems like a lot of pain (language complexity, programmer errors, unreadable programs, etc) for no gain.
In some sense, yes, continuations are funky syntax for using callbacks. You can manually perform a very complex global transformation on your code (the so called continuation-passing-style transformation), and you will get continuations on your hands without direct language support.
However, transforming your entire codebase is probably not very practical, and the resulting code is hard to read, so having the compiler do it for you behind the scenes is MUCH better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With