Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60764 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32407 invoked from network); 6 Jun 2012 19:23:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2012 19:23:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:34626] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/30-29813-33EAFCF4 for ; Wed, 06 Jun 2012 15:23:32 -0400 Received: by lbgc1 with SMTP id c1so5617470lbg.29 for ; Wed, 06 Jun 2012 12:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=fLLyGjl8AFCLFBosJoEFjzgNklxTzW8hsJogqCUD/Nc=; b=0UFYooer/BnpWk0hg5qIXPtfJQwbYxiTG8xSHX+d+y+lDy+p8pHMk5GgJdjDo4kFQI KYvsTgzc91/9BFJCvtnCaVWZ0UaCmv4CrDTCId9d2OUibfX08o92YdFLrE/PFZSzniCH Mn6VFuLtpj271KmwkNJdPCLVUorAO7Cyr9o8DWycnvYrIH/d42T16MSsrLJ3oG7Ts761 k/ZpTM5Jk5t6sAN5E3gLQPydFIIubi5cKgxDOMYIEX5I3bsulpizbq6eCp3LHH6NEc/x Nen150ecONL3MjNYokkwKBLSYV/HHfxMDyiFNJdDESwLGk7CAlZ6uzRkRudxD6IFsZgo fGdg== MIME-Version: 1.0 Received: by 10.152.124.141 with SMTP id mi13mr22690725lab.50.1339010607954; Wed, 06 Jun 2012 12:23:27 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Wed, 6 Jun 2012 12:23:27 -0700 (PDT) In-Reply-To: References: Date: Wed, 6 Jun 2012 21:23:27 +0200 Message-ID: To: Laruence Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Generators in PHP From: nikita.ppv@googlemail.com (Nikita Popov) On Wed, Jun 6, 2012 at 4:15 AM, Laruence wrote: > Hi Nikita: > > =A0 =A0the most important part to me is how did you implemented `yield` > keyword, =A0 is there a whole patch file I can look into? > > =A0 =A0what will happen if you use a `yield` in a normal function? > > =A0 =A0actually, =A0I tried to implemented coroutine, but since I could n= ot > find a way to make zend_execute interruptable, then I didn't make it. Yes I also faced that problem. The current execute() function accepts an op_array and initializes the execution context from that (execute_data + CVs + Ts). So I added a new function execute_ex() which takes that execution context directly. The execute() function now works by initializing the execute_data using a new zend_create_execute_data_from_op_array() function and then calls execute_ex() with it. The most relevant commit for this change is https://github.com/nikic/php-src/commit/f627be52540738e124da7cb1566d7f60a2b= 6a48b. Nikita