开发者

Are there any programming languages where continuations restore the heap in addition to the stack?

开发者 https://www.devze.com 2023-02-17 15:22 出处:网络
Languages that I am familiar with with support for continuations (Scheme and Ruby) restore the stack state and instruction pointer from when the continuation was created. I am wondering if there are a

Languages that I am familiar with with support for continuations (Scheme and Ruby) restore the stack state and instruction pointer from when the continuation was created. I am wondering if there are any programming languages where invoking the continuation restores the heap as well?

[EDIT:] In addition to Marcelo's answer that I accept开发者_StackOverflowed I also found an extension to ML that supported the concept of "stores" which are effectively what I describe. See the paper Refining First Class Stores by Greg Morrisett.


Since all objects are immutable in Haskell, I think it's safe to say that a continuation would restore the entire state of the process, including the heap.

It would be interesting to figure out how that affects I/O and other monadic behaviours. I'll hazard a wild guess that the type system won't allow a return back to the state before an I/O event occurred. (A continuation is itself a monad, so you probably can't interleaved it with I/O.)

Caveat: I barely know Haskell, so the above comments could be a laughable pile of nonsense.

0

精彩评论

暂无评论...
验证码 换一张
取 消