From: Dan Doel Date: 2003-08-07T09:32:32+09:00 Subject: Re: Why does Ruby have callcc? As for why callcc takes a block (I didn't see this in any of the replies so far)... If you look at Scheme's call-with-current-continuation, it's syntax: (callcc f) Where f is the function you want called. callcc then calls: (f cc) Where cc is the continuation, so you'd often see something like: (callcc (lambda (cc) (my-fun cc arg1 arg2 ...)) Which makes an anonymous function that accepts the continuation and passes it, along with some other arguments, on to another function that does stuff. Now, to do this in ruby (most easily), you'd do: callcc { |cc| my_fun cc, arg1, arg2 ... } Since blocks are similar to lambda constructs. The other option would be to use actual methods for callcc, but then you'd be creating all kinds of one-argument methods just to call other methods, and that's really the job of a block or a Proc. And if you want to see something that you need callcc to do, you can search the mailing list for Callcc and insomnia (or something like that), where I was experimenting with them and made, more or less, a class that mimics Python's generators (or what Parrot calls coroutines) with them. That's not exactly a practical application (although I do use them in the code for my web page), since it's essentially implementing more language functionality that you may or may not use, but I find that sort of thing interesting, at least. Cheers. - Dan