Hey:

On Tue, Sep 1, 2015 at 2:51 PM, Stanislav Malyshev <smalys...@gmail.com> wrote:
> Hi!
>
>> I agree that at first it will feel a little bit weird, especially
>> given that PHP in general lacks syntactic sugar (we still don't have a
>> short-hand to initialize stdclass objects). We introduced [] back in
>> 5.4, and largely it has made readability FAR better (despite some
>> people saying it wouldn't at the time).
>
> That doesn't mean now we have to drop all keywords and switch to
> write-only style. Even [] was somewhat controversial, though it is the
> most elementary syntax construct. Function call is in no way elementary
> - it has non-trivial structure, and obscuring this structure by removing
> keywords does not help readability.
>
>> tool isn't always appropriate in all situations. You can craft code
>> that makes this new syntax look unreadable. But you can craft code
>
> The problem is not that I can. The problem is that anybody can, and a
> lot of people would, unwittingly, once the expressions get more complex
> that $x+1.
>
>> that makes this look far more readable.
>>
>> Example:
>>
>> function partial(callable $cb) {
>>     return function($left) use ($cb) {
>>         return function($right) use ($cb, $left) {
>>             return $cb($left, $right);
>>         };
>>     };
>> }
>
> It is a bit verbose but pretty clear what's going on here - function
> returns a function that returns a function, and you can easily track
> which variable goes where and how it gets to the end.
>
>>
>> vs:
>>
>> function partial(callable $cb) {
>>     return $left ~> $right ~> $cb($left, $right);
>> }
>
> It looks very pretty as the ASCII art, and no entry-level programmer
> would have any idea at all what these arrows actually do and how this
> thing is supposed to work. At least not without studying the manual very
> closely for extended time. That's exactly the problem. People start
> writing overly clever code that looks so pretty - and then other people
> are left scratching their heads about what actually is happening there.
> That's what I mean by write-only code.
>
>> It may look weird at first, but consider that's because you're not
>> used to the syntax. To me, the top is far harder to follow because of
>
> Of course, with enough training you can get fluent even in APL. I know
> people that are. But PHP is supposed to be on the other end of the
> spectrum.
>
>> the shear number of tokens to follow, not to mention that I need to
>> pay attention to the use-blocks which may or may not be importing
>> certain variables. The bottom reads exactly how I would expect it to.
>
> That's because you wrote it and know in advance what it is supposed to
> do. It's not a good test of readability.

+1, that is what readable(guessable) means.....

thanks
> --
> Stas Malyshev
> smalys...@gmail.com
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
Xinchen Hui
@Laruence
http://www.laruence.com/

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

Reply via email to