Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61787 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55776 invoked from network); 25 Jul 2012 18:08:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2012 18:08:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; 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:59022] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/0E-19281-E2630105 for ; Wed, 25 Jul 2012 14:08:47 -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 5C871C30002; Wed, 25 Jul 2012 14:08:43 -0400 (EDT) Message-ID: <50103616.8040508@ajf.me> Date: Wed, 25 Jul 2012 19:08:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Dave Ingram CC: PHP Development References: <500EE3B9.8010902@ajf.me> <500EEA76.1030407@ajf.me> <5010138D.5050804@ajf.me> <501015B9.6050704@ajf.me> <501026DB.6030507@ajf.me> <501033C6.8040603@dmi.me.uk> In-Reply-To: <501033C6.8040603@dmi.me.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 25/07/12 18:58, Dave Ingram wrote: > >> 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. > Just to put my oar in too, as an interested watcher... > > I don't think that it's a problem (from that point of view) to have a > generator keyword. Explicitly declaring up front that it's a generator > means that the "return" keyword in the body is always a mistake. > Likewise with "function" and "yield". I don't think it would be > confusing to have something that looks like a function but isn't > completely the same. In fact, it's almost (but not quite) like > declaring a return type for the function. > > > D > I just don't think there's much point in it. Generators (with this syntax) are still functions, they just suspend execution. Also, other languages (e.g. Python) have added generators without special syntax, seemingly without issues. -- Andrew Faulds http://ajf.me/