Re: [RFC] Short syntax for anonymous functions
| From: | Mark | Date: | Fri, 15 Mar 2013 14:43:53 +0000 |
| Subject: | Re: [RFC] Short syntax for anonymous functions | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-66645@lists.php.net to get a copy of this message | ||
On Mon, Feb 25, 2013 at 1:17 PM, Clint Priest <cpriest@zerocue.com> wrote:
>
> On 2/21/2013 5:17 AM, David Muir wrote:
>>
>> On 21/02/2013, at 6:12 AM, Lazare Inepologlou <linepogl@gmail.com> wrote:
>>
>>>
>>> Long code is not always equivalent to readable code. A shorter syntax
>>> could
>>> improve readability in *some* cases.
>>>
>>> Long:
>>> $users->OrderBy( function( $x ){ return $x->Surname; } );
>>>
>>> Short:
>>> $users->OrderBy( $x ==> $x->Surname );
>>>
>> I think your example proves the opposite. The fist example was much easier
>> to read and understand than the second.
>
> That all depends on how many languages you're versed in, the short syntax
> above is common in many modern languages and has no clarity issues for me.
>
>
> --
> -Clint
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Just letting my voice hear as a "php developer" watching this list
from time to time.
As a php developer i'm heavily against adding this "feature" to php.
It makes the code very vague to understand and specially if it's
spread over multiple files.
For example file_a.php has:
$sayHi = { echo "hi"; };
Now lets say file_b.php has this:
$sayHi();
This is just code obfuscation! Please don't add it. It would be neat
as a code obfuscation technique :)
Just my 5 cents.
Cheers,
Mark