3 ms·
Can someone explain https://github.com/billhails/PyScheme/wiki/Here https://github.com/billhails/PyScheme/wiki/Here ? The example warped my brain a little.
by FPGAhacker 8y ago
Can someone explain https://github.com/billhails/PyScheme/wiki/Here https://github.com/billhails/PyScheme/wiki/Here ?
The example warped my brain a little.
- bjoli 8y agoIt is just call/cc from scheme. Here calls a function with the current continuation which means you can either do an early return, like the example where they "replace" the current continuation with the value 3. In scheme you can save that continuation and return to it as many times as you want, which people from other languages have a hard time to wrap their head around. I'm rather sad that they chose to implement undelimited continuations, since that is almost never what you want. First class continuations are a fantastic tool in your language. They can be used to implement coroutines, fibers, nondeterminism and so on. Really no surprise that they are a part of scheme, which usually pick a few well thought out primitives that combine into nice high level abstractions.