jastrachan | 15 Apr 20:12 2004
Picon

Re: Generators


On 15 Apr 2004, at 19:03, Stepan Koltsov wrote:
> Opps, you are right :-)
>
> BTW I can implement both Generators and Generator Expressions (second 
> is
> easier, but first is more useful and interesting) :-)

Yep, no worries.

> James hasn't told anything yet.

Agreed - apologies, I'm suffering email backlog.

> And. I was wrong about the necessity of using threads to implement
> generators. I was fooled by the implementation of generators in Python.
> I'll comment issue a little later.

Cool.

There's generators which could be cool to support, then there's support 
for the 'yield' statement. Up to now you can kinda spoof that via 
closures...

myGeneratorFunction(Closure yield) {
     for (i in 1..10) {
	yield i
     }
}

So its not really a language feature right now, its literally we just 
invoke the closure to simulate a yield. Though we might wanna do real 
yields like python/ruby/C#. But this is kinda like a mini-continuation 
inside a single method.

James
-------
http://radio.weblogs.com/0112098/

Gmane