On Sat, 04 Dec 2004 08:59:24 -0700, David Green <plato@edmc.net> wrote: > In article <198c87380412032209261dcb17@mail.gmail.com>, > mddiep@gmail.com (Matt Diephouse) wrote: > >Supposing > > class Filehandle does Iterate; # Iterate or Iterator? > >we have an easy way to create new iterators. I'm not sure how useful > >they would be in Perl 6 > > Maybe the class doesn't do it, but one of its methods does? Then you > can call it whatever makes sense. C<does Iterate> signifies a role named "Iterate". Roles are sort of a mix of interfaces and mixins (as I understand it -- I'm still waiting for E12). So saying a class fulfills a role just means that it provides certain methods. In this case, I was saying class with the Iterate role would provide a C<.next> method. > >Which be even cuter like this (I think): > > for iter($sth.execute) -> $results { ... } > >where iter creates an Iterator object that just knows to call C<.next> > >on its argument. > > That still seems too cumbersome to me. Isn't it "for" that knows to > call .next (or .sequel, whatever)? I'm thinking that that is the > point of "for $foo", which should be approximately the same as "while > $foo.next". We've got "while" for looping, ".next" for iterating, > and "for" for doing both in one convenient little shortcut. But for needs to know if it has an iterator or a list. You don't want it iterating over things you didn't want it iterating. In this case, I was suggesting making an, though I suppose something like C<$sth.execute> could just return one. > >Hoping I haven't removed all doubt of my foolishness, > > I'm hoping this reply reassures you. Thanks. -- matt diephouse http://matt.diephouse.comThread Previous | Thread Next