"Yasuo Ohgaki" wrote in message news:caga2bxzpud0j86d-vlsc+fukhzrjk_3qu_5afkg0bm+de7x...@mail.gmail.com...

Hi Anthony and Bob,

On Tue, Sep 1, 2015 at 2:53 PM, Anthony Ferrara <ircmax...@gmail.com> 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



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to