Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60781 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17837 invoked from network); 8 Jun 2012 11:24:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2012 11:24:54 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:38033] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/45-19215-401E1DF4 for ; Fri, 08 Jun 2012 07:24:54 -0400 Received: by lagy4 with SMTP id y4so1303744lag.29 for ; Fri, 08 Jun 2012 04:24:49 -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; bh=f6OuxUYBa4Zf/j9GZsreUlIcnfmFdqdEkKmTYzhOSN8=; b=KtHlKbDnZsfPOW+3rYvAqsstAL33Q/lc3M8dAZDgr0qxVGMPuAbqLMuQ1EZwH3k8KJ Ic8BMvf92LDm0kLAwnHfPDYYZ2Ku43qs6SkWRFht1hQS+EMpANCGTMEQrI4FRhRKV3Qw Th7QicLqIqLy2hYvMhSEb/vGtJRG42u3uBtausKuXyJtNfMfW5IWdw0qk/UchY9XYNeW gV4DCDY0HAF1RHn+Cq4lYtY9+NZyJASesFywmpru2uGJCKyNFPVSbgYGBP5rs3Opb8Lg i5rUtlCJ7QsAOnYSj1NkDQi04ZybT3uleyKfvArxRmT3SOFVZlNXYtVIey9e34gWmiy2 S9uQ== MIME-Version: 1.0 Received: by 10.152.148.170 with SMTP id tt10mr7696678lab.48.1339154689709; Fri, 08 Jun 2012 04:24:49 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Fri, 8 Jun 2012 04:24:49 -0700 (PDT) In-Reply-To: <3dfb58cfcdefa75813fa670231040c7b@nebm.ist.utl.pt> References: <5361275d0179dd0f3061ceabf7bde9af@nebm.ist.utl.pt> <3dfb58cfcdefa75813fa670231040c7b@nebm.ist.utl.pt> Date: Fri, 8 Jun 2012 13:24:49 +0200 Message-ID: To: Gustavo Lopes Cc: internals PHP Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Generators in PHP From: nikita.ppv@googlemail.com (Nikita Popov) On Thu, Jun 7, 2012 at 10:46 AM, Gustavo Lopes wrote: > I mean how do you deal with "return $foo" in the body of the generator? Does > it work like a final yield? Is the return value ignored? Currently there will be a fatal error if return statements (with values) are used in the generator. In the future I'd like to use the return value as the result of a yield from / yield* expression, as it is currently done in Python and JavaScript. This is particularly useful if you are delegating control to another coroutine. This way you can for example break down a coroutine-based parser into several functions (instead of having one big ugly function). > Are you planning on any internal API for functions to implement generators > (though I really haven't thought how that would work)? I don't think that this is possible. Generators require that the execution context is suspended in some way and we have to that control only over userland code, not internal C code. Nikita