Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61840 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12859 invoked from network); 27 Jul 2012 13:31:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jul 2012 13:31:34 -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:44528] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/55-14209-53892105 for ; Fri, 27 Jul 2012 09:31:34 -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 0A387C30004; Fri, 27 Jul 2012 09:31:28 -0400 (EDT) Message-ID: <5012981B.3090406@ajf.me> Date: Fri, 27 Jul 2012 14:31:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Lester Caine CC: PHP internals References: <500EE3B9.8010902@ajf.me> <500EEA76.1030407@ajf.me> <5010138D.5050804@ajf.me> <501015B9.6050704@ajf.me> <501058B9.5050004@lsces.co.uk> <501249B6.5070507@lsces.co.uk> <50128825.4020902@lsces.co.uk> In-Reply-To: <50128825.4020902@lsces.co.uk> 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 27/07/12 13:23, Lester Caine wrote: > Nikita Popov wrote: >>> I'll ask again since no one has answered ... >>> > >>> >In a different way ... >>> >Is the only thing that changes the 'function' into a 'generator' >>> replacing >>> >the call to process the data with 'yield'? ( That would be >>> 'SUSPEND' in an >>> >SQL procedure ) ... >>> > >>> >So how DOES an IDE work out the flow in order to correctly check that >>> >variables are defined? >>> > >>> >As always, my IDE provides a lot of 'sexy' stuff so that I don't >>> need to >>> >have it built in to the language, and I still can't see how a lot >>> of what is >>> >being loaded in helps with performance which is the only thing that >>> I am >>> >interested in. Performance wise why is yield better than just directly >>> >calling a function to handle the data? >> Lester Caine and Alex Aulbach, >> >> may I ask you to continue this discussion in a separate thread? I am >> really interested in constructive responses about the generator RFC, >> but your discussion is generating a lot of noise, which makes it very >> hard for me to pick out the few mails that are of interest to me. >> >> If you could open a new thread (like "Generator keyword") it would >> help a lot. > > Nikita - I am looking for a well reasoned argument as to why generator > has to be added at all! 'Just because it can be' is not a valid > argument, but perhaps you could add to the RFC the performance > implication or advantage of what is being proposed. That would at > least be some comparison with the current methods of doing the same > thing? > Argh. I am trying to avoid this completely ridiculous thread of discussion that has grown well beyond any reasonable length. But I should just say this. Generators are being added because they make things easier. The function-with-yield model of writing iterators is much easier, faster, and far less verbose than manually creating a class and implementing the iterator interface. This is why they are being added. They also might be a bit faster than Iterator classes, I don't know. But the main point is they are a powerful feature that greatly simplifies creation of iterators. I will not discuss further on this point. -- Andrew Faulds http://ajf.me/