Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61785 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50241 invoked from network); 25 Jul 2012 17:03:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2012 17:03:49 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.133 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.133 oxmail.registrar-servers.com Linux 2.6 Received: from [64.22.89.133] ([64.22.89.133:55603] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/1D-19281-4F620105 for ; Wed, 25 Jul 2012 13:03:49 -0400 Received: from [192.168.0.200] (5ad32874.bb.sky.com [90.211.40.116]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 4296BC30003; Wed, 25 Jul 2012 13:03:44 -0400 (EDT) Message-ID: <501026DB.6030507@ajf.me> Date: Wed, 25 Jul 2012 18:03:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Alex Aulbach CC: Ferenc Kovacs , Sherif Ramadan , internals@lists.php.net References: <500EDCC7.1020402@ajf.me> <500EE3B9.8010902@ajf.me> <500EEA76.1030407@ajf.me> <5010138D.5050804@ajf.me> <501015B9.6050704@ajf.me> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Generators in PHP From: ajf@ajf.me (Andrew Faulds) On 25/07/12 17:54, Alex Aulbach wrote: > 2012/7/25 Andrew Faulds : >> Experience can be helpful. But you must support things with facts > Ok, I tried to bring all the pro arguments together. > > Suggestion: > > For a generator, rename the keyword "function" to ... "generator" or > something like that. Example: > generator hugo() > { > yield ... > } > > Fact: yield/generators is more or less complicated, this shouldn't be > changed - it's a proven concept. > Fact: yield makes functions some kind of "different". > Fact: It doesn't matter how much difference and if PHP has already > "different" behaving functions. We're talking about now. > Fact: It doesn't matter how it is implemented in other languages, > because we talk about PHP and not other languages. > Fact: This is also good style in general: Call the things what they are. > Fact: as PHP-developer we must try to avoid making things more > complicated, because this is one of the best features of PHP. > Fact: it's easy to implement a new keyword into PHP for that case > > Experience: Most PHP programmers will have problems to understand > generators because it is a function that generates an iterator... > something magic they never heard of before. > Experience: generators/yield can't be explained on one page. Much > programmers will never ever read so much docs. :) > Experience: good features are self-explaining. A function which > returns an iterator because of a simple word in it's body is not. > Experience: They will make stupid mistakes, because they mix yield > function with normal functions. > Experience: They will make stupid mistakes, because they will look for > "return" instead for "yield". > Experience: again, yield is more or less complicated, it's in this > case not a good idea to cover complexity by using already existing > language constructs. > Experience: Not using the same name will remove a little bit pressure > from "busy" programmers > Experience: It's of course their fault, if the don't learn how to use > something. But this is against the concepts of PHP. This means: If we > have the chance to make things easier we must do it. > Experience: The current concept dosn't "feel right" for me. I like to > listen to my belly in those questions, because he is in most cases > right. With the change I suggested he stops grumbling. > > Please correct me if I use arguments I thought they have been > generally agreed/some of them are new. > > - > Alex Aulbach > Fact: Adding a new name for a special kind of function as a syntax construct is going to cost (possibly unnecessary) time and energy, because now you have functions, and weird things that look almost like functions but aren't and can only be used to make generators. -- Andrew Faulds http://ajf.me/