commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Horman" <>
Subject RE: [functor] generators
Date Fri, 25 Apr 2003 05:19:22 GMT
Generators were added to python in version 2.2

Ruby was built with generators in mind.

Simple Python generator:

def gen():
    for x in range(1, 10)
        yield x

for num in gen():
	print num;

My generator has a very simple interface. Basically:

public abstract class Generator {
    public abstract void run(UnaryProcedure proc);
    public void stop();
    public boolean isStopped();

Generators run, and call proc for each item generated. The run method should
check isStopped on each internal iteration. Python's approach to stopping
iteration is to throw a StopIteration exception. That may be fine practice
in Python but is looked down upon in Java, though I think it is a more
flexible approach in many ways.

I will send you the source to generators directly.


-----Original Message-----
From: Arnd Kohrs []
Sent: Thursday, April 24, 2003 2:41 AM
To: Jakarta Commons Developers List
Cc: Jason Horman
Subject: Re: [functor] generators


thanks for this inspriring introduction to Generators.  As far as I
understood Generators try to compensate for the lack of internal
iterators in common datatypes together with the other advantages that
you exposed.  Do you have any pointers to the subject of generators?
Generators could be a good addition to the functors.

Can you please send me a copy of the source please, or post the full
interface of Generator.

Further, I think that the addition to sandbox functor should not be
delayed too much so that emailing of source code is not necessary.
After all it's a sandbox.  But this is just the opinion of a nobody (no
commiter at all).


Arnd Kohrs  -  Castify Networks  -  +33 492 94 2093

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message