Re: resume after exception

From: Date: Tue, 03 Apr 2012 14:06:41 +0000
Subject: Re: resume after exception
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-59345@lists.php.net to get a copy of this message
Sam, Just to be clear, I wasn't opposing pythonic generators. I was opposing using this feature for that purpose. If we wanted generators, I would suggest implementing them fully (as in adding a yield statement). However, that's not going to be as easy as it sounds, since what would happen with a function like this: function foo(array &$array) { foreach ($array as $value) { yield $value; } } $array = array(1); foreach (foo($array) as $value) { $array[] = $value + 1; } Not saying it's not doable, just that it's not trivial to implement... Anthony On Mon, Apr 2, 2012 at 5:51 PM, Samuel Giles <sam.e.giles@gmail.com> wrote: > Hi Anthony, > > Ok, I see that now. I know you're not necessarily saying what's been > proposed is a good idea but I can see a benefit in pythonic style generators > as a separate piece of functionality, implementing a yield function, has > this ever been discussed before? My apologies if this is the case I've not > seen it since I've been following this list. > > I know there is the SPL Iterator, but just as in the example you provided > implementations *can* be verbose and convoluted. > > Cheers, > Sam > > On Mon, Apr 2, 2012 at 10:34 PM, Anthony Ferrara <ircmaxell@gmail.com> > wrote: >> >> Sam, >> >> I'm not saying it's a good idea, but this would allow for pythonic >> style generators.  http://wiki.python.org/moin/Generators >> >> Just pointing out one potential use-case... >> >> Anthony >> >> On Mon, Apr 2, 2012 at 4:35 PM, Samuel Giles <sam.e.giles@gmail.com> >> wrote: >> > My major concern would be, how does this* really* add to PHP?  Perhaps >> > I'm >> > missing the point, but what would this allow that can't be done in some >> > form using well defined "patterns", for lack of a better word. >> > >> > I'm not keen on the idea of throwing things such as Interrupts either, >> > it >> > doesn't quite fit with their general use case. >> > >> > Sam > >

« previous php.internals (#59345) next »