Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62238 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79576 invoked from network); 18 Aug 2012 13:19:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Aug 2012 13:19:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:54499] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/56-31572-0769F205 for ; Sat, 18 Aug 2012 09:19:45 -0400 Received: by lahl5 with SMTP id l5so2656155lah.29 for ; Sat, 18 Aug 2012 06:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=OzUlQH3Vij2ZO6glcZtQIdjdtGZRH7ahWYFEqZr39AY=; b=Oevx8R8GZB/p7AK7PF0CPcsvnB9KNJKPdtgMglZLPHsqAj57btuirhBnSea3FObR3J jOAgPNYaAeS5AHmO4n0t0mKJZMFbFXL8qqA7VW22/bHe62A7xMs0pSoVMBTAhywvMk3t teGQw61fKVKlwfRqPP0dvK2Wh/1b1OdVgzsm3nbn+788wXWMt6dazktj2ZDA2CxRi9Tl +KwO2sLUcuSkJGyxIsDwCl2vLZ2ltvO8S3j6CEj1bLPzRRiFAEM1fFkN1voMHR/+xFBp ALJ9CxI/xGwbg7NDmFFDYKsFDA/alvn9FHFepdEsrBHaC7/6aVIR2eTp/I93ST/mSgKi Sjbw== MIME-Version: 1.0 Received: by 10.152.108.42 with SMTP id hh10mr8297615lab.9.1345295981643; Sat, 18 Aug 2012 06:19:41 -0700 (PDT) Received: by 10.152.122.51 with HTTP; Sat, 18 Aug 2012 06:19:41 -0700 (PDT) In-Reply-To: References: Date: Sat, 18 Aug 2012 15:19:41 +0200 Message-ID: To: Derick Rethans Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Generators From: nikita.ppv@gmail.com (Nikita Popov) On Sat, Aug 18, 2012 at 2:21 PM, Derick Rethans wrote: > I've some comments how that I've read the RFC: > >> Recognition of generator functions >> >> 1. Any function which contains a yield statement is automatically a >> generator function. >> >> 2. The initial implementation required that generator functions are >> marked with an asterix modifier (function*). This method has the >> advantage that generators are more explicit and also allows for >> yield-less coroutines. >> >> The automatic detection was chosen over the asterix modifier for the >> following reasons: > > I am against this. This is even more magic in PHP. Is it really that > difficult to have to mark the function with a different keyword, such as > "generator": There was already a rather long discussion on this topic. Most of it is noise, but I filtered out a few mails from Sara and Rasmus as they probably are of most interest: http://markmail.org/message/xzhdhbjozb4yrhh3 http://markmail.org/message/ryhygtimpd7q2nok http://markmail.org/message/32fklwqykpk56iph http://markmail.org/message/w2kbh7psplnmctcr >> yield: Yields the value null with an auto-incrementing integer key. > > What is the usecase for this? Use case is `$data = yield;`. In that case you don't care about what you yield (so just the default value and key are yielded), you are only interested in what you get sent back. Nikita