Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66856 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89103 invoked from network); 29 Mar 2013 10:10:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Mar 2013 10:10:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain zend.com does not designate 209.85.128.172 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.128.172 mail-ve0-f172.google.com Received: from [209.85.128.172] ([209.85.128.172:33935] helo=mail-ve0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/00-22694-5A865515 for ; Fri, 29 Mar 2013 05:10:46 -0500 Received: by mail-ve0-f172.google.com with SMTP id oz10so402619veb.3 for ; Fri, 29 Mar 2013 03:10:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=mFz2vvly69WurmmIXnkm24wRfRvWVo9DIEj5FEE9l20=; b=KNZYQKqnoD/C5r0VU1LSXlHbNAVkQxDxXuuK5gchLrllo7aT6rcsknoaBWf/E8RMhV 6jx0qdo2IPbDmxUX6TVfjKhrqi60uxh+X+u8HwQy3tc+PC9cnXkRjf4mSzjwoO+BdPR8 IgRnljrSGOmaGnBDatCkgLv50a2HmhfB3432xuz1aaiLGZ8wKUR5BSXEZJU/CGf6ct6h Lsw9AvpuZX3UzjFF37pgbEgeTgmw1rtjtYbiiGQn86zKiMs9GdPwqi8pyeiwAJJqdQKO e3n/zfyVdHRpGixaqBDlK/TSLDrJSwLTazYaLKF1l2l5RybxnlOL09sTvC+ElAcglNEI oWWw== MIME-Version: 1.0 X-Received: by 10.52.65.147 with SMTP id x19mr1210073vds.27.1364551843387; Fri, 29 Mar 2013 03:10:43 -0700 (PDT) Received: by 10.52.70.132 with HTTP; Fri, 29 Mar 2013 03:10:43 -0700 (PDT) In-Reply-To: References: Date: Fri, 29 Mar 2013 14:10:43 +0400 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=20cf3071ca04e737ee04d90d7b43 X-Gm-Message-State: ALoCoQlyoBLrlKhT5ppUcY1fB5CtvH2YljQYB6n0fGcAcaeRhyd0MJkEgythsC0gCth9g8POSenjU+vVgNW18YSqT+eGWHU9i38eQ5gXpehZgnGJrDROS6ASxi5PgZxW6ptmy68OyOlH Subject: Re: [PHP-DEV] Remove support for cloning generators From: dmitry@zend.com (Dmitry Stogov) --20cf3071ca04e737ee04d90d7b43 Content-Type: text/plain; charset=UTF-8 I agree. The less tricky code the better :) Thanks. Dmitry. On Mon, Mar 25, 2013 at 9:16 PM, Nikita Popov 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 > --20cf3071ca04e737ee04d90d7b43--