Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87986 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45202 invoked from network); 1 Sep 2015 09:19:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Sep 2015 09:19:32 -0000 Authentication-Results: pb1.pair.com header.from=pajousek@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pajousek@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.180 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.223.180 mail-io0-f180.google.com Received: from [209.85.223.180] ([209.85.223.180:32871] helo=mail-io0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/43-27722-3AD65E55 for ; Tue, 01 Sep 2015 05:19:31 -0400 Received: by iods203 with SMTP id s203so188479729iod.0 for ; Tue, 01 Sep 2015 02:19:28 -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=8YK/c0OYsTuPHQ3i9RP8RsgtcEDvy4FG2mxsOJeu/5g=; b=rQHoo6Fz18mceyVe5HYNZhvsyUy0ZtjTNlmCuHuXs5O1W9O0NHfGyzWF1pvyOtoQwE J//cL14kNVl1cwwu+A+ATyZclRXQ75UJwnRcNbjF0NNcGpA0kxP+ruBApyc9HUZ2m71C J43vEU67/zdDQwBe9L1AgOCEV29rHtuNUVWAvlJQ7Y3IG2T34XvGvkwtADZIbL9qGSqD Yc77+OSkQlSjeThzoUQ1WxwVHlY801Ceo8eP5iwL0N89QqTctLiyMww0wfRccPC4Zx2H wgOhza7Q6EKsUGdY/7keWlbw5fNs+R7+0/9n4vU4oyJLEUC4GBaN0mAimIB0XFSrhKyy +irw== MIME-Version: 1.0 X-Received: by 10.107.47.193 with SMTP id v62mr29674802iov.13.1441099168759; Tue, 01 Sep 2015 02:19:28 -0700 (PDT) Received: by 10.107.24.194 with HTTP; Tue, 1 Sep 2015 02:19:28 -0700 (PDT) In-Reply-To: <3D.61.27722.AB565E55@pb1.pair.com> References: <55E4C19F.4060704@gmail.com> <55E4F029.10104@gmail.com> <7BCB36EE-56C8-441F-BF40-954D9FA912A9@lerdorf.com> <55E51FAA.8030106@gmail.com> <3D.61.27722.AB565E55@pb1.pair.com> Date: Tue, 1 Sep 2015 11:19:28 +0200 Message-ID: To: Tony Marston Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] [Discussion] Short Closures From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) On Tue, Sep 1, 2015 at 10:45 AM, Tony Marston wrote: > > 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. > The thing is, every feature and syntax can be used to create some unreadable "monstrosity". And often, at the same time, they can be used to create readable elegant code. :) Sure, "elegant" and "readable" is subjective, and for someone who never heard of FP, this might be befuddling. But so is probably the entire concept of anonymous functions and high order functions. Does it mean PHP shouldn't support passing functions to functions at all? I think not. Also, once you know ~> is a syntax sugar for anonymous functions (and understand them), I don't think there's any general readability problem, and in some cases, it makes the code even more readable (subjective experience from other languages). And if the programmer doesn't understand the concept of anonymous functions at all, he will be lost anyways and shorter or longer syntax doesn't matter. I personally wouldn't even mind just having a version that supports [variables] ~> [single expression], but since other languages support having whole function body with return statement, I think it's worth considering adding it too. Regards Pavel Kouril