I agree. The less tricky code the better :)

Thanks. Dmitry.

On Mon, Mar 25, 2013 at 9:16 PM, Nikita Popov <nikita....@gmail.com> wrote:

> Hi internals!
>
> Now that we're in the beta phase I want to put some finishing touches on
> the generators implementation. The first thing I'd like to do is remove
> support for cloning generators. There are a few reasons for this:
>
> a) The cloning basically works, but the implementation is rather fragile
> and easy enough to break. I just had another look at the code and found two
> new ways to make it segfault. I could fix those issues, but I'm pretty sure
> that they are not the only bugs in there (that's in the nature of that
> code).
>
> b) Especially if objects are involved, the cloning can result in weird
> behavior. E.g. if a generator is cloned that makes use of an SplStack,
> after cloning both generators will make use of the same stack, which makes
> little sense. Just cloning all objects instead of just adding a ref doesn't
> make sense either, because cloning would be the wrong thing to do for
> objects passed as arguments. One would basically have to clone only objects
> created inside the generator, or something like that, which is not
> technically possible.
>
> c) Most importantly, there is very little use for the cloning. At first I
> thought it would be nice to use cloning in order to implement forking when
> using coroutines as a means of multitasking, but this doesn't really work
> well due to b). Apart from that I can think of no use for cloning at all.
>
> Patch for removing cloning is here:
>
> https://github.com/nikic/php-src/commit/805b244d8f106431f01b5c013d4e66f9bb88d09b
>
> If no one objects I'll commit it sometime soon.
>
> Thanks,
> Nikita
>

Reply via email to