From: Alex Shinn Date: 2002-02-06T10:41:30+09:00 Subject: Re: Call/CC and Ruby iterators. >>>>> "Thaddeus" == Thaddeus L Olczyk writes: Thaddeus> Reading about call/cc in Scheme I get the impression that Thaddeus> it is very like Ruby's iterators. Not being an expert in Thaddeus> others I thought I would ask. Yes. And bumblebees are like jumbo jets :) Iterators loop over each element of a class. However you define them they will go from start to end and you can't interrupt them in the middle. Continuations capture the current lexical environment and program location and wrap it up as a first class procedure. You can then store it away and call it later at any point to achieve non-linear control flow. Continuations make it easy to implement things like exception handling and cooperative threading. Of course, Ruby supports closures as first class objects so you could probably get something continuation-like in Ruby - just don't try it with iterators. And continuations lose a lot without proper tail recursion. -- Alex def y(&le)lambda{|f|f.call(f)}.call(lambda{|f|le.call(lambda{|*x|(f.call( f)).call(*x)})})end