Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62312 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88190 invoked from network); 20 Aug 2012 20:46:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Aug 2012 20:46:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=alex.aulbach@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=alex.aulbach@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: alex.aulbach@gmail.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:35653] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/78-07742-A02A2305 for ; Mon, 20 Aug 2012 16:46:02 -0400 Received: by yenm10 with SMTP id m10so5952880yen.29 for ; Mon, 20 Aug 2012 13:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=p03KtBIOt48OK27jqTUCFfsGk6YHKlUraxPcCCYAASs=; b=esMGvB8LLqSfEnBaTmBHvMlyqbSzbR5U01GhydQRww82g4nF5UJSMBBjis6Gjiw4tK DXJTh95FAr6ymA6NY7kENqxZM7+lvY53t59J2D3dgYujyYVOIHVJXUgHgH+oZmP4HJY0 Sn+MxsI5athUrEqVh3ihJQM3kIrRYOPpDytz9DleMk0BvaLIkoO1fIBWvnx6816+6Q/i H9D2y9fIfdlyoKCiG3MdD2njUs9VrWxwIWdFH8/SJnJ/X2GgqMB1ZQaSAn2lTGiAIk3y sL6G+WHDRme+5w7mlTih433ud0h9jzEZBLkbJpiGt7JtToVlrPLHYWRevkZi6nD0+c2G F6RQ== MIME-Version: 1.0 Received: by 10.50.180.129 with SMTP id do1mr11225303igc.28.1345495559448; Mon, 20 Aug 2012 13:45:59 -0700 (PDT) Received: by 10.64.141.36 with HTTP; Mon, 20 Aug 2012 13:45:59 -0700 (PDT) In-Reply-To: <503298F2.6090801@gmail.com> References: <503171CB.3090609@sugarcrm.com> <50317E51.4090305@lerdorf.com> <503225D8.4040900@gmail.com> <503298F2.6090801@gmail.com> Date: Mon, 20 Aug 2012 22:45:59 +0200 Message-ID: To: =?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?= Cc: Nikita Popov , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Generators From: alex.aulbach@gmail.com (Alex Aulbach) I think this doesn't bring anything further to talk about how to implement this in the parser. After reading the thread again, I would like to say that - either this should be implemented as currently defined - or it is implemented with the generator-keyword. But then it isn't a function anymore, because that's is ridiculous. In that case it should look like this: generator g() { yield; return; } 2012/8/20 =C1ngel Gonz=E1lez : > On 20/08/12 15:12, Nikita Popov wrote: >>> You could not decorate it and rely instead on the presence of the yield >>> keyword, but parsers will thank knowing about it from the start rather >>> than realising at mid-parsing that the function is a completely >>> different beast. >> No, parsers don't care about this. It's trivial to detect in both cases. >> >> Nikita > Yes, it's trivial to detect, but how much work is for it to do so? > Suppose the parser reads php code and outputs machine instructions. When > it encouters a function(), it adds the function prologue, goes reserving > stack > space for the variables it encounters, and so on. Then you find a yield > keyword. > Options: > - Discard the generated code and go back to the function begin, using > this time > an storage into an object instead of the stack. > - Copy all the state to an object and return it. > - Add an initial pass checking which functions are generators. > > PHP being a dynamic language, it may be able to move the function variabl= es > to a class. But it's not trivial for any parser. > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Freundliche Gr=FC=DFe Alex Aulbach