Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60758 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98440 invoked from network); 6 Jun 2012 10:39:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2012 10:39:35 -0000 Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-gg0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:41169] helo=mail-gg0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/84-08677-6633FCF4 for ; Wed, 06 Jun 2012 06:39:35 -0400 Received: by ggnf2 with SMTP id f2so5386917ggn.29 for ; Wed, 06 Jun 2012 03:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=exdI3zDk3JErGEqFCZQVkCQTvWkPMwBNGGrvEjOs/5E=; b=0iTMiEl0pKWA3rbgasOl9zO3zpwqKa9NzKgqTxZvC7XLuWexS1u0aDqf4K2ULSiWO1 UE6tLo+NAccqziEDx1cvdB4a1xSKt/4sYqiqOU2pBinbjv1BxODq3EgYjWjHuBIPNXVr 0puljaQAPh+HMOthESP5Dpcw1PRb78+sVf/EMBlnzyfz0UhoiBD3sIBw/AWVkwuVa73F uQvzU0nxtTsrFCXOhpWRLTDfM7hI9fZr9Z2klb4PRktk8kW6864B6XvjabTqYI8AOa+x EReNj7xXeKVbgi+ChwpqUc+bMjUKm08FsTpUCG0OIj8jo2i2NsxgrRmR79Fh2w90Dm+s 1VJw== Received: by 10.236.72.40 with SMTP id s28mr15440559yhd.21.1338979172230; Wed, 06 Jun 2012 03:39:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.146.153.7 with HTTP; Wed, 6 Jun 2012 03:39:12 -0700 (PDT) In-Reply-To: <4FCF2F09.8050904@hoa-project.net> References: <4FCF2F09.8050904@hoa-project.net> Date: Wed, 6 Jun 2012 12:39:12 +0200 Message-ID: To: ivan.enderlin@hoa-project.net Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf30051314ec241504c1cb61b1 Subject: Re: [PHP-DEV] Generators in PHP From: linepogl@gmail.com (Lazare Inepologlou) --20cf30051314ec241504c1cb61b1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello Ivan, Moreover, I wonder how a =E2=80=9Crecursive yield=E2=80=9D would act (somet= hing like > =E2=80=9Cpublic function *f ( =E2=80=A6 ) { =E2=80=A6 yield $this->f(=E2= =80=A6); =E2=80=A6 }=E2=80=9D). It is possible? Is > it anticipated? > According to the RFC, your syntax will yield an entire generator and not its intividual values. Please consider this example: function * f() { ... } function * g() { yield f(); } function * h() { foreach( f() as $key =3D> $value ) yield $key =3D> value; } The pattern in function h() is quite common, and it is what you ask for. It would be nice to have some syntactical sugar for it, maybe something like that: public function * h() { yield foreach f(); } Good work, I am looking forward to having generators in php. Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel 2012/6/6 Ivan Enderlin @ Hoa > On 05/06/12 19:35, Nikita Popov wrote: > >> Hi internals! >> > Hi Nikita, > > Before going any further I'd like to get some comments about what you >> think of adding generator support to PHP. >> > I have always hoped to see the =E2=80=9Cyield=E2=80=9D keywork introduced= in PHP. I even > suggested that in this mailing-list at least one time but I'm very glad t= o > see some patches coming out. > > In addition to Gustavo's remarks, I wonder how the GC would collect a > Generator object that is not use anymore (especially with a referenced > yield). Does it fit to the current CG strategy or do we need an extra > strategy? I would notice that the =E2=80=9CYield by reference=E2=80=9D se= ction does not > exist but you have targeted it). > Moreover, I wonder how a =E2=80=9Crecursive yield=E2=80=9D would act (som= ething like > =E2=80=9Cpublic function *f ( =E2=80=A6 ) { =E2=80=A6 yield $this->f(=E2= =80=A6); =E2=80=A6 }=E2=80=9D). It is possible? Is > it anticipated? > > Thanks for you work. > > Cheers. > > -- > Ivan Enderlin > Developer of Hoa > http://hoa.42/ or http://hoa-project.net/ > > PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) > http://disc.univ-fcomte.fr/ and http://www.inria.fr/ > > Member of HTML and WebApps Working Group of W3C > http://w3.org/ > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --20cf30051314ec241504c1cb61b1--