Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61784 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48705 invoked from network); 25 Jul 2012 16:54:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2012 16:54:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=alex.aulbach@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=alex.aulbach@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: alex.aulbach@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:52356] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/CC-19281-1E420105 for ; Wed, 25 Jul 2012 12:54:58 -0400 Received: by vcbgb30 with SMTP id gb30so856026vcb.29 for ; Wed, 25 Jul 2012 09:54:55 -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=nnseOjMKdhHxrPHCvuVl1DGKZ72q+8SDL9qXOv/55qU=; b=q9Jv3gOx0vcfQ4aegCtn9OMqi1x5k0Pj4mmfJ38rBGy9A9Xs+O7br22yQk8Djh6LFi 58mkfjULGQ+Ry3pRxvtvnjibfRtZdR4q8EVvI14SkWMpNDL+t7d8Tg1SJumSv4rIQVPQ KdvnmVDUJAKuiJWk5CMIo+K5/qA37PgI6Z+rp0sJc+1DFi0ArEVOFsQSTZAs2snbHaiC nvY6MfKKoTOH6K16X8pi1HH9C63y+oN0JVBThtPn6QW2hP6hfzNgFfOykCCkUH7pDmNW a4QxQaSvajKMTt+Kp2VzS5Fo1ouI1S3q+S159LC81GJC5uCN5Oo63Woa51Vt2JwnPzqW kpKA== MIME-Version: 1.0 Received: by 10.52.71.137 with SMTP id v9mr16525526vdu.63.1343235295148; Wed, 25 Jul 2012 09:54:55 -0700 (PDT) Received: by 10.58.249.177 with HTTP; Wed, 25 Jul 2012 09:54:54 -0700 (PDT) In-Reply-To: <501015B9.6050704@ajf.me> References: <500EDCC7.1020402@ajf.me> <500EE3B9.8010902@ajf.me> <500EEA76.1030407@ajf.me> <5010138D.5050804@ajf.me> <501015B9.6050704@ajf.me> Date: Wed, 25 Jul 2012 18:54:54 +0200 Message-ID: To: Andrew Faulds Cc: Ferenc Kovacs , Sherif Ramadan , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Re: Generators in PHP From: alex.aulbach@gmail.com (Alex Aulbach) 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