Re: Re: [RFC][Discuss] Arrow Functions
| From: | Levi Morrison | Date: | Fri, 03 Feb 2017 20:46:53 +0000 |
| Subject: | Re: Re: [RFC][Discuss] Arrow Functions | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98147@lists.php.net to get a copy of this message | ||
On Fri, Feb 3, 2017 at 1:37 PM, Niklas Keller <me@kelunik.com> wrote:
> 2017-02-03 21:23 GMT+01:00 Levi Morrison <levim@php.net>:
>>
>> On Fri, Feb 3, 2017 at 12:18 PM, Andrea Faulds <ajf@ajf.me> wrote:
>> > Hi David,
>> >
>> > David Rodrigues wrote:
>> >>
>> >> Hello folks!
>> >> I just not understand why "function" should be abbreviated. It's
>> >> about
>> >> "how
>> >> less character better"? I don't see it too much on PHP. I guess that is
>> >> more simple keep what exists current "function", that all knows about
>> >> (that
>> >> should be better than the next example):
>> >>
>> >> $mapped = array_map(function($x) => $x + $y); // vs current:
>> >> $mapped = array_map(function($x) use($y) { return $x + $y });
>> >
>> >
>> > I feel the same way. It would be nice to have shorter syntax, but it
>> > sacrifices readability and familiarity here, and adds yet another new
>> > keyword.
>> >
>> > It also feels inconsistent… isn't "fn" just short for
>> > "function"? Why is
>> > it
>> > exclusive to the => syntax?
>>
>> This is not exactly on topic... unless you are implying you'd prefer
>> the
|$x| => $x + $y? Maybe you missed [this][1] message?
>
>
> Why is using "function" instead of "fn" not on topic?
I did not ask for general syntax suggestions. What I am asking about
is specifically what the preference people might have between these
two options:
fn(params) => expr
|params| => expr
As well as potential issues (thanks, Ilija, for pointing out a
theoretical issue with union types).
----
As a disclaimer I'm trying to guide the discussion to these two
options, not suppress suggestions I don't like.