Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62118 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26432 invoked from network); 12 Aug 2012 20:08:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2012 20:08:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=brian@moonspot.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=brian@moonspot.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain moonspot.net designates 72.5.90.26 as permitted sender) X-PHP-List-Original-Sender: brian@moonspot.net X-Host-Fingerprint: 72.5.90.26 mail.dealnews.com Linux 2.6 Received: from [72.5.90.26] ([72.5.90.26:52883] helo=mail.dealnews.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/FD-00812-74D08205 for ; Sun, 12 Aug 2012 16:08:39 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.dealnews.com (Postfix) with ESMTP id E376F617B19D; Sun, 12 Aug 2012 16:08:34 -0400 (EDT) X-Virus-Scanned: amavisd-new at dealnews.com Received: from mail.dealnews.com ([127.0.0.1]) by localhost (atl-zimbra1.dealnews.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id czml17DXfc3x; Sun, 12 Aug 2012 16:08:23 -0400 (EDT) Received: from Brians-MacBook-Pro.local (h105.248.18.98.static.ip.windstream.net [98.18.248.105]) by mail.dealnews.com (Postfix) with ESMTPSA id A9AC2617D143; Sun, 12 Aug 2012 16:08:23 -0400 (EDT) Message-ID: <50280D37.10109@moonspot.net> Date: Sun, 12 Aug 2012 15:08:23 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Nikita Popov CC: PHP internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Generators From: brian@moonspot.net (Brian Moon) Hi Nikita, I admit, I have ignored these threads as there was no RFC. So, some of this may have been covered. Do you have a good example usage other than a file? I don't find fopen/fgets/fclose all that complicated. What are the other valid use cases for such a thing? Also, not allowing rewinding is unintuitive for something that is an iterator in PHP. If I can foreach() it and I can call next() on it, I expect to be able to reset() it as well. IMO, you would need to issue a FATAL PHP error if that simply is not allowed. Or you have to have a second syntax for what to do in that case. At that point, you are implementing Iterator. While I am glad that PHP has borrowed syntax from many languages, I find the yield keyword to be very WTF when I first saw it. It is also poorly explained in your RFC. You use terms like "sending and receiving". That does not say "returns from function execution" to me. I had to basically figure it out from the code examples. Lastly, because you cite needing this for sending data to PHPUnit, I think this is a user land problem and not a core problem. In about 5 minutes I implemented a reusable Generator object that does exactly what you need. http://pastebin.com/V336rEpR At least, it does what your examples show you need. Again, file IO is very easy and perhaps that example does not explain your true need very well. Brian brianlmoon@php.net http://brian.moonspot.net/ On 8/11/12 8:42 AM, Nikita Popov wrote: > Hi internals! > > I think there already was a lot of discussion on the generators, so > it's time to move to the next step. I'd like to vote on the feature in > two weeks, so this the "announce[ment] on internals@, by the author, > with the intention of voting on it". > > https://wiki.php.net/rfc/generators > > If you have any further feedback, now would be a good time to raise > it. If there is something you previously posted, but which I didn't > yet address, please let me know. There were around 150 mails and I > sure missed some of them. > > Thanks, > Nikita >