16 Apr 2004 09:05
Re: Generators
On 15 Apr 2004, at 21:06, Bill Burdick wrote:
> I think continuations fit better with the Java semantic model, but
> implementing fast continuations is not for the faint of heart. Scheme
> systems that support fast continuations model them at the lowest level
> of the VM and Java doesn't do that.
Agreed.
Maybe a 'simple' version of a continuation could be done on a 1 method
scope. e.g. supporting the 'yield' statement from ruby, python, C# etc.
myGenerator() {
yield 1
yield 2
yield 3
}
or
myGenerator() {
for (x in 1..3) {
yield x
}
}
which we can turn into an iterator...
for (y in myGenerator) { ... }
so its like a continuation just in 1 method scope in that it maintains
its local variable state & can be restarted where it left off. Though
this would be confined to a single method and only the methods which
use 'yield' rather than a true continuation which needs to preserve &
restore an entire call stack - and needs to do this in any method
anywhere just in case you're in the call stack when a continuation is
used.
James
-------
http://radio.weblogs.com/0112098/
RSS Feed