Proposal idea - generators

Mark Derricutt mark at
Tue Mar 24 12:07:49 PDT 2009

Hi all,

This isn't an actual proposal, but more a proposal idea that hopefully
someone could run with.  I was thinking about all the closures issues
and looking at a lot of my code where I'm using closure like patterns
and started thinking what would really make things easier for me would
be some form of yield/generators api to give me a cleaner way of
making Iterable's that could be used in the JDK5 for loop.

The usage I'd like would be something like:

for ( User user : allUsersList) {
  if (user.isActive()) yield user;

Effectively I could see this as being like comparing an XML pull
parser to SAX.  The problem I have is I can't think of a suitable way
of expressing, or implementing this in java, unless I split the code
into another thread that sleeps between the yield calling back to the
iterable next() call which is nasty as I could see a lot of thread
leakage there.

Has anyone looked at, or already written some form of generator proposal?

...and then Buffy staked Edward.  The End.

More information about the coin-dev mailing list