I like the suggested syntax. The only drawback I see is that it inhibits the 
future addition of union types for closures:

    |int | float $x| => $x

Adding parentheses of course resolves the issue but looks a bit awkward:

    |(int | float) $x| => $x

Apart from that I have nothing to complain about. I'd be happy either way.


On 3 Feb 2017, 21:24 +0100, Levi Morrison <le...@php.net>, wrote:
> On Fri, Feb 3, 2017 at 12:18 PM, Andrea Faulds <a...@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?
>
> [1]: http://news.php.net/php.internals/98136
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Reply via email to