Hacker News new | past | comments | ask | show | jobs | submit login
Teach Yourself Scheme in Fixnum Days (2015) (ds26gte.github.io)
185 points by tempodox on May 28, 2018 | hide | past | favorite | 26 comments



This book is another model for concise technical writing, like K&R or the Awk book that was recently discussed here. I learned much of what Scheme I know from it, and it didn't take long. I recommend it for learning or emulation.


Which awkward book are you referring to?



This is a great book to read if you're in the process of writing your own how to book, so great on so many levels from writing style to content flow.


The best book to mimic in my opinion is "Learn You a Haskell for Great Good!"

link: http://learnyouahaskell.com/chapters


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.


Right. 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?


Continuations 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.


It 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.


For 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.


Andy Wingo uses delimited continuations to implement guile fibers 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.


I 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/


Chicken 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.


Look up LambdaNative.org. It is based on Gambit, and will run on all common platforms. And I think you mean Kawa Scheme, not Kiwi.


I 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.


It 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." ?


Perhaps the thinking is that it abstracts both the if branch and the else, and only one of them gets executed?


The rest of the program only executes once you apply the continuation. Maybe splitting hairs though.


I 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.


Is there a handbook or something akin to "Scheme for C Programmers"? I think I can manage with other options and this position looks promising. But I'm quite often in a C mindset and it would be helpful to see how some idioms can be translated - for example typical integer arithmetic.


Anyone have a Mobi for this?


Not exactly what you have asked for but you can find the LaTeX sources of the book at https://github.com/ds26gte/tyscheme with instructions of building a PDF version.


I didn't see the mobi format listed, but pandoc can create eBooks from TeX source: https://pandoc.org/MANUAL.html https://pandoc.org/epub.html


Calibre is very good at converting epubs to mobi (and the other way around.) It ships with a commandline tool called `ebook-convert` too so you don't have to mess around in the GUI.

https://manual.calibre-ebook.com/generated/en/ebook-convert....


If you can pass the clunky interface and cryptic error message from that badly designed app.


Yes the UX design is very poor, but the core conversion functionality works well once you figure out how the awful GUI works. The `ebook-convert` commandline tool is just fantastic though. It has a very straight forward interface.

    ebook-convert input_file output_file [options]
And there isn't very much impedance mismatch between mobi and epub, so the conversion back and forth between the two will almost always be high quality.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: