Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66805 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47255 invoked from network); 25 Mar 2013 17:16:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Mar 2013 17:16:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.179 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.179 mail-ob0-f179.google.com Received: from [209.85.214.179] ([209.85.214.179:46594] helo=mail-ob0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/C7-07007-47680515 for ; Mon, 25 Mar 2013 12:16:37 -0500 Received: by mail-ob0-f179.google.com with SMTP id un3so6232570obb.10 for ; Mon, 25 Mar 2013 10:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=Esn7dIdz0V4MiUgYENb8J2wIrcQ3DDhofljO3Qd94h0=; b=j3IVVOx9YZUC9DCfbYlczU4XqSU1jpBBCrLV3iEkiZcl7pPIEwfQtONKHE3zxs5oFT xx0tQC0zaJG3vbnOMdeOa7R7hZcFZpiEP2/CqWgd7AK1Pf1J2IqUdXWEyEO5Q4Syk9YG NnGgm1bl/+bGtXhXuKts4TPdn/4/DOOcyvv3oeZKLQIYKyet2/zc82KlWNfBNiyjLNmn RYXEsAf000zYy49aGlUTbJvUpZkSbG4xqd1Je4/aA3mwPKLTR1GCQGUfczLXoVcPkwjg psKPZzy4JyGwQGnreoLKS1aPF7Y1BcdXKt6MWMGDzipj1X9e3FD+F15+1EQ4a+dsBOX5 G7dg== MIME-Version: 1.0 X-Received: by 10.182.155.66 with SMTP id vu2mr482831obb.6.1364231793949; Mon, 25 Mar 2013 10:16:33 -0700 (PDT) Received: by 10.182.49.136 with HTTP; Mon, 25 Mar 2013 10:16:33 -0700 (PDT) Date: Mon, 25 Mar 2013 18:16:33 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=f46d04479faf7843f504d8c2f78a Subject: Remove support for cloning generators From: nikita.ppv@gmail.com (Nikita Popov) --f46d04479faf7843f504d8c2f78a Content-Type: text/plain; charset=ISO-8859-1 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 --f46d04479faf7843f504d8c2f78a--