简体   繁体   中英

Is there something like stateful continuations or continuations with saved heap?

In functional programming, continuations are very useful because continuations store the program counter and stack; mutable heap is not necessary to save obviously.

What about if you want to apply continuations in non-functional programming languages like Java, JavaScript, etc? Here, we should save the mutable heap to correctly resume a program if you need. I was looking for a technique like continuations that we can use in this kind of language (eg Java), but I could n't find it. Do you know something about this?

I don't think typical continuation implementations support the automatic tracking of the heap, but it is definitely something that can be added relatively easily.

For example, the Seaside web framework uses continuations to model the flow of displayed components. Since saving the complete heap would be expensive, developers can register which objects they like to track . This works by creating a snapshot at the time the continuation is created, and restoring the object at the time the continuation is resumed. This enables to automatically restore application state as the back- and forward buttons in the browser are used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM