3 ms·
But Haskell’s execution model has no underlying support for continuations, and yet there are perfectly efficient implementations. You actually can not implemen
by tathougies 9y ago
But Haskell’s execution model has no underlying support for continuations, and yet there are perfectly efficient implementations.
You actually can not implement delimited continuations in languages like c++, javascript, or go, unless you write your own execution environment at which point Id argue you’ve left the realm of the language. In c++ at least, such an implementation would certainly use undefined behavior
- rbehrends 9y ago> But Haskell’s execution model has no underlying support for continuations, and yet there are perfectly efficient implementations. What you need is a way to capture and manipulate stack frames at a very basic level. Haskell cannot magically avoid that. As I recall (though it has been a while), Control.Monad.CC reifies stack frames explicitly. Monads function in this context as a very basic metaprogramming technique (or as some sort of AOP, if you want to look at it this way). > In c++ at least, such an implementation would certainly use undefined behavior This is what I mean by support in the execution model. You do need to have access to stack frames, and C++ doesn't permit that. There are workarounds [1], but they generally require non-trivial metaprogamming, due to the insane complexity of C++. You don't have that problem with, say, Smalltalk, as most Smalltalk VMs gives you the necessary functionality. For example, one of the original continuation-based web frame works, Seaside, was all Smalltalk [2]. [1] http://www.filpizlo.com/papers/baker-ccpe09-accurate.pdf; http://www.filpizlo.com/papers/baker-ccpe09-accurate.pdf; the context here is GC, but the underlying problem is similar, access to stack frames (in this context, for root scanning). [2] http://seaside.st/about/examples http://seaside.st/about/examples