Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87981 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35913 invoked from network); 1 Sep 2015 08:45:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Sep 2015 08:45:50 -0000 X-Host-Fingerprint: 80.177.120.119 marston-home.demon.co.uk Received: from [80.177.120.119] ([80.177.120.119:23851] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3D/61-27722-AB565E55 for ; Tue, 01 Sep 2015 04:45:48 -0400 Message-ID: <3D.61.27722.AB565E55@pb1.pair.com> To: internals@lists.php.net References: <55E4C19F.4060704@gmail.com> <55E4F029.10104@gmail.com> <7BCB36EE-56C8-441F-BF40-954D9FA912A9@lerdorf.com> <55E51FAA.8030106@gmail.com> In-Reply-To: Date: Tue, 1 Sep 2015 09:45:38 +0100 Lines: 2 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 X-Posted-By: 80.177.120.119 Subject: Re: [PHP-DEV] [RFC] [Discussion] Short Closures From: TonyMarston@hotmail.com ("Tony Marston") "Yasuo Ohgaki" wrote in message news:CAGa2bXZpUd0J86D-VLSC+fUKhzRJk_3Qu_5afkG0bM+DE7XYew@mail.gmail.com... > >Hi Anthony and Bob, > >On Tue, Sep 1, 2015 at 2:53 PM, Anthony Ferrara >wrote: >> Most programming languages today have a "short form" closure or lambda >> syntax >> >> HackLang: ($x) ==> $x + 1; >> C++: [](int x) -> int { return x + 1; } >> Java: (int x) -> x + 1; >> Python: lambda x: x+1 >> Ruby: lambda |x| { x + 1 } >> Rust: |x| x + 1 >> JavaScript (ES6): x => x + 1 >> C#: x => x + 1 >> Objective C: ^(int x) { return x + 1; } > >Nice summary! >The syntax may look strange at first, but proposed syntax is close enough >to >other languages. There will be no barrier for our users in the long run. This argument is irrelevant for several reasons: (1) I am not familiar with any of those languages, nor are many PHP users. (2) Just because other languages have such a feature is not a good reason for adding it into PHP. (3) Introducing write-only (less readable or completely unreadable) code will ALWAYS be a barrier to those who have used nothing but PHP for the last 10+ years. As H. Abelson and G. Sussman wrote in 1984: "Programs must be written for people to read, and only incidentally for machines to execute." Writing compact code which has several functions compressed into a single line may be clever where you come from, but it leaves new readers scratching their heads saying "WTF!!". As a follower of the KISS principle I always aim to write simple, readable code, and my critics always say "It is too simple. Proper OO is supposed to be more complex than that". The mark of genius is to achieve complex things in a simple manner, not to achieve simple things in a complex manner. -- Tony Marston