4 ms·
The part on continuations is like every other explanation on them - too brief, too cryptic. Although I myself understand them, I doubt a newbie would from readi
by i_feel_great 8y ago
The part on continuations is like every other explanation on them - too brief, too cryptic. Although I myself understand them, I doubt a newbie would from reading this.
Overall it is good and concise.
- wiz21c 8y agoIt reads : >>> The current continuation at any point in the execution of a program is an abstraction of the rest of the program. Shouldn't it be : "The current continuation at any point in the execution of a program is an abstraction of the rest of the execution of the program." ?
- i_feel_great 8y agoThe rest of the program only executes once you apply the continuation. Maybe splitting hairs though.
- jimhefferon 8y agoPerhaps the thinking is that it abstracts both the if branch and the else, and only one of them gets executed?
- klez 8y agoRight. Also, I still haven't found an explanation of continuation that told me why I should use them or even with a practical example showing me more than incrementing a number at every call. Is my Google-fu failing me? Does anyone have a link to an explanation that doesn't require a bachelor in maths to understand?
- i_feel_great 8y agoIt is right there in the "Escaping continuations" section. Escaping early means you can use it to write simple things like "drop" and "take", and lazy evaluation. I believe, though I do not know for sure, that this is how lazy evaluation is implemented in lisps, including Clojure. Also it allows you to write a threading implementation like coroutines in another section below. Generally it does this: you have a process, say that does A, B, C, D and E. You let it run and save it at, say "C". The continuation is the rest of the process, "D" and "E". So now you go and do something else, say a process from J to U. Somewhere in there, you can whip out your continuation and it does "D" and "E". You are simply bookmarking something to do later because you gotta go do something else. In coroutines, you run one, stop and save the continuation and switch to another, run, stop, save and switch, and so on and so on, and then jump back and resume the original etc.
- thelastidiot 8y agoFor the fact that you have to explain in a paragraph or two what are continuation, I don't think the material in the book is doing a good job.
- bjoli 8y agoAndy Wingo uses delimited continuations to implement guile fibers https://github.com/wingo/fibers/wiki/Manual https://github.com/wingo/fibers/wiki/Manual It is a low level construct that can be used to build higher abstractions and things like coroutines. In a language like scheme they can also be a (costly) way to do early escapes. If you are into nondeterminism they are also quite usable. call/cc is being retired in favour of delimited continuations, which is a good thing. Most often you don't need them. Implementing things like generators using continuations is possible, but it is also a lot slower than built in support for generators.
- hawski 8y agoI just started learning a bit of Scheme. From what I read Chicken Scheme has very cheap call/cc. Even its domain name is call-cc.org. Is that very rare around Scheme implementations? Currently I'm thinking about Kawa for Android, maybe Bigloo for Windows (.NET) and Gambit for everything else. And I start to wonder how different implementations have different properties even among compiled ones. Edit: a typo: s/Kiwi/Kawa/
- i_feel_great 8y agoLook up LambdaNative.org. It is based on Gambit, and will run on all common platforms. And I think you mean Kawa Scheme, not Kiwi.
- hawski 8y agoI read about it - it uses Gambit everywhere and draws its own widgets. On Android it has to use JNI. I'm thinking about wxWidgets in Scheme, but with almost none FFI penalty on every platform.
- bjoli 8y agoChicken has free call/cc due to the Cheney on the MTA memory management. This is very rare. Most often it doesn't matter much, since call/cc is rare enougn. I would still prefer delimited continuations since they are easier to reason about. Most often you pick one implementation and stick with it. Scheme is not like CL where you can run the same program on many different implementations without much fuss. Chicken is a very nice implementation with the most friendly IRC channel on freenode.
- olavk 8y agoContinuations can be used to implement higher-level constructs like exceptions, generators, async calls and so on. For a language like Scheme which prefers a few powerful primitives, it gives the user the power to implement such constructs on their own. Most mainstream languages prefer to keep such powerful tools out of the hands of users, and instead provide higher-level constructs like exceptions, generators, async etc. as part of the core language. It is a trade-off between power and consistency (like macros) - the trade-off which is the stuff of language flame-wars. There is nothing "mathy" about continuations to my understanding. They are like GOTO, a low-level construct which can be used to implement higher-level constructs which are more appropriate in regular applications. Basically, continuation captures the program counter (the address of the current instruction) and the current environment and stack. This allows you to "save" (like in a computer game) the current execution state, and then restore it as needed.
- thelastidiot 8y agoI had exactly the same impression. I jumped right into that section, because that's what makes or break an howto book on the Scheme language. That part should definitely be rewritten.