flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > Partial continuations |
Author |
|
revolution 02 May 2015, 00:35
Do you mean something like state saving for hibernation, suspension or migration of a task?
|
|||
02 May 2015, 00:35 |
|
nyrtzi 02 May 2015, 06:27
revolution wrote: Do you mean something like state saving for hibernation, suspension or migration of a task? http://en.wikipedia.org/wiki/Delimited_continuation Yes, kind of. If a continuation is the machine code combined with a snapshot of the state of a program including the stack at that point so that I can jump back to that point in time and continue from there then yes I guess it could be used for that too. One common example of what continuations can be used for is that of implementing backtracking algorithms. If one common problem with continuations is that they switch the entire the execution context so that they never return unless you pass them another a continuation telling where to return. A partial continuation is supposed to be a slice of a continuation created so that it actually does return to the caller automatically when done and thus can be treated like a function. I'm trying to figure out the implementation alternatives so I could the make an informed choice between support for continuations, partial continuations or coroutines based on the trade-offs involved. People seem to say that implementing coroutines is trivial if you have continuations. But I'm wondering if what you gain by supporting continuations is worth the pain compared to coroutines which I assume can be used just by creating a new stack for each instance and then passing the arguments and jumping to the entrypoint. And then there is the question of multiple entrypoints and exits with different signatures. I'm assuming that coroutines might make this a little more intuitive use if supported. Continuations and partial such seem to be more parts of the whole program as a big ball of mud while I kind of find it easier to imagine coroutines as separate modules. Modularity being a good thing. And if I were to go towards coroutines there might not be that huge of a leap towards actors if I were to want to experiment with them too. The main issues here are the same as usual with continuations, coroutines, etc. To go for a cactus stack or multiple linear ones? Will the caller or the callee save registers? How should parameter passing work? Do we need return values or will output parameters suffice? Pretty basic but fundamental decisions which need to be made. Unless I can go for cheap prototypes and test a whole variety of different approaches. With the partial continuations I'd need to figure out what a compiler supporting them would generate to make them happen. How do I create just a slice of the future of a program or in other words of the snapshot? Save the registers and other state on the stack and add code which restores all of it from the stack? Copy the stack starting from the top, fix the pointers and after I come to the mark which designates where the continuation needs to be cut I gather up the bindings in the lexical frames below it and insert a return instruction to make the continuation return like a partial one should? Oh well. Time to eat and to leave the rest of the ponderings for the afternoon. |
|||
02 May 2015, 06:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.