On Tue, Sep 1, 2015 at 10:45 AM, Tony Marston <tonymars...@hotmail.com> 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

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

Reply via email to