Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60765 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34249 invoked from network); 6 Jun 2012 19:33:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2012 19:33:07 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:51495] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/90-29813-270BFCF4 for ; Wed, 06 Jun 2012 15:33:07 -0400 Received: by werm13 with SMTP id m13so5186313wer.29 for ; Wed, 06 Jun 2012 12:33:03 -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; bh=rizSZ/aY8jQ42ZWO0yoX836wuToZSVGj/IPZbccempI=; b=Y6LlKuEkmFDPwZ9BTalTTSXJVneTNLCdfZ0DPiqWCXlReYkkydtDyBSR0AuXyrdbFr GnJCcQndsHEWIfq8TC3NBG10xjB1pt8WvxVfnxenVeGVaWbtsYf2lH41RF/nMtjfqUr+ hwSfiHa8LcSkevT/pYMUipqe+SwaqqxMsiKa0sFcANN3IhP7kt6ssNfR12vEyg9XLS6q +cQi58K7JhsmnUEAfJkJm1/pgTasHbmADT6tG8ls/5bmbR2LFZlb5R6M+/5hO469+jSX vkBs6iz0IIrK9Db56MjRlz3fMddvNvy+c2z1g2vTW4ankZ95H5aZh+lX8k6vdxTiq9MU x14w== MIME-Version: 1.0 Received: by 10.216.141.98 with SMTP id f76mr17981993wej.32.1339011183441; Wed, 06 Jun 2012 12:33:03 -0700 (PDT) Received: by 10.223.160.133 with HTTP; Wed, 6 Jun 2012 12:33:03 -0700 (PDT) In-Reply-To: References: Date: Wed, 6 Jun 2012 12:33:03 -0700 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=0016e6de17b3f0790f04c1d2d537 Subject: Re: [PHP-DEV] Generators in PHP From: kris.craig@gmail.com (Kris Craig) --0016e6de17b3f0790f04c1d2d537 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jun 6, 2012 at 10:09 AM, Nikita Popov wrote: > On Tue, Jun 5, 2012 at 8:32 PM, Kris Craig wrote: > > Some observations and questions: > > > > In the RFC, the top example claims to make use of the file() function, > but > > in fact does not. Did you mean fopen()? Or did you mean that this to > be an > > example of someone writing their own file() function in PHP for some > reason > > (the "userland" reference is a bit confusing IMHO given the context). > It's an implementation of the file() function in userland code (as > opposed to the internal file() implementation). file() returns all > lines from a file as an array. > > > In what way(s) do you believe this approach would differ from inline > > functions and what advantage(s) do you see in those differences? > I'm not sure what you mean by inline functions. PHP doesn't do > function inlining (and it doesn't seem related to this). Or do you > mean closures? Again, I'm not sure how closures are related to this. > Yes sorry, I meant closures. I have the nasty habit of calling them "inline functions," forgetting that that term already means something completely different lol. I guess the point I was making is that *closures* and generators are very similar in many ways. This isn't to say that generators are a bad idea (I actually think it's an awesome idea), but the question occurred to me as to whether or not generators will add any functionality that can't already be accomplished (albeit somewhat more clumsily) via closures. I tend to think the answer to that probably lies in yields, but I think it would be beneficial to address this-- along with some examples to illustrate this advantage over closures in appropriate use-cases-- in the RFC. I agree with Stas that, while it's a great idea, the RFC itself is far from complete. > > > What release version do you believe should be targetted for this? > The next major version, i.e. PHP 5.5. > Ok good. Just wanted to make sure we weren't talking about squeezing this into 5.4 lol. Personally, I think RFCs should specify the target PHP version when applicable. I know it's not required but I think it'd be a good idea to get in that habit anyway IMHO. --Kris > > Nikita > --0016e6de17b3f0790f04c1d2d537--