Re: An implementation of a short syntax for closures
| From: | Lazare Inepologlou | Date: | Thu, 04 Aug 2011 08:58:40 +0000 |
| Subject: | Re: An implementation of a short syntax for closures | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-54342@lists.php.net to get a copy of this message | ||
Hello,
>> $add = | $x |=> | $y : $x |=> $x+$y;
> Not sure that it's really readable.
This is not the most trivial example. In my blog, there is a small
sub-section where I explain why this is more readable than an implementation
with the current syntax. See under "Readability" and "A more complicated
example".
http://linepogl.wordpress.com/2011/08/04/short-closures-for-php-an-implementation/
:-)
Lazare INEPOLOGLOU
Ingénieur Logiciel
Le 4 août 2011 10:50, Frédéric Hardy <frederic.hardy@mageekbox.net> a écrit
:
> Hello !
>
>> I've always thought that just supressing the "function" keyword could work
>> as a shorthand, i.e. having ([param1 [, param2 [, ...]]]){...}. Somewhat
>> similar to Ruby's lambda shorthand:
>> http://slideshow.rubyforge.org/ruby19.html#40
>>
>>
> Huge +1 for that.
> Code using closures will be more readable.
>
>> $add = | $x |=> | $y : $x |=> $x+$y;
>>>>
>>>>
>>> Not sure that it's really readable.
> Moreover, it's more Perl/Ruby way than PHP way.
>
> Best regards,
> Fred
>
> --
> ========================================================================
> Frédéric Hardy : Architecte d'application/Admin. système/Ergonome
> CV :
> http://blog.mageekbox.net/public/cv.frederic.hardy.pdf
> Blog : http://blog.mageekbox.net
> Twitter : http://twitter.com/mageekguy
> ========================================================================
>
>