Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61725 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92835 invoked from network); 24 Jul 2012 19:16:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2012 19:16:53 -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:56850] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/00-27263-3A4FE005 for ; Tue, 24 Jul 2012 15:16:53 -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 E0D3AC30038; Tue, 24 Jul 2012 15:16:47 -0400 (EDT) Message-ID: <500EF488.5080403@ajf.me> Date: Tue, 24 Jul 2012 20:16:24 +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: Gustavo Lopes , Yahav Gindi Bar , internals@lists.php.net References: <500EDCC7.1020402@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 24/07/12 20:13, Alex Aulbach wrote: > 2012/7/24 Gustavo Lopes : >> When you have function foo() { ... yield /* ... */; ... } and >> you call foo(), you get the same thing every time: a Generator object. It so >> happens that the implementation of that object is inside the body of the >> function. > Hmmm. It's not that I didn't understand it. :) > > My thoughts are about usage in practice. Ok, my first argument with > the developer, who overtakes an old project was weak. > What about situations, when developers with different knowlegde work together? > > Or when you have programming errors, when you write > > function blubb() > { > ... yields... > ... > ... return.... > } > > (you may only see the "return"). > > And many those situations are thinkable, because this kind of PHP > function works so totally different from current. > > >> Maybe this helps you reason about the feature. > Please understand me, it's not that I don't like it or that I couldn't > live with it. It's because I have too much experience what could > happen if new programming features are introduced. > > For example: Exceptions in PHP are quite old now. And the concept of > exceptions should be known. But I worked together with programmers > wich produced code like > > ... > try { > $value = method_which_throws_exceptions(); > } catch (...) { > return $value; > } > return $value; > ... > > And he has it done, although I wrote some example code for him how to > use exceptions in this context!!11! > > > THAT'S the reality. > > We can ignore that, but I just want to make such simple mistakes not > so easy and the afford is worth the results. > > You can argue: "Those mistakes will always happen". I say "Yes, of > course, but if we have the chance to reduce those mistakes we should > do it." > It's fairly obvious from context these aren't ordinary functions, IMO. And anyway, what could possibly go wrong? Is there any incorrect but non-fatal or warning-generating way you could use them? -- Andrew Faulds http://ajf.me/