On Sat, Oct 3, 2015 at 1:17 AM, Levi Morrison <morrison.l...@gmail.com> wrote:
> I messaged the list about this feature before I had the RFC written up
> for it. The RFC[1] is slightly different from what I proposed in the
> previous thread, so please read the RFC to make sure you understand
> what is being proposed before replying here.
>
> Here's a small example:
>
>     $y = 10;
>     $result = array_map(function($x) => $x + $y, [1, 2, 3]);
>
>     // $result is [11, 12, 13]
>
> Thanks for people who have participated in conversation so far, as
> well as those who participated in Bob's short closures proposal as
> well.
>
>   [1]: https://wiki.php.net/rfc/arrow_functions
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Hello,

thanks for another proposal on this feature. :)

As I said in the previous e-mails, I'm not really fan of the
"function" prefix - because it has the same prefix as the "long
declarations". Just by removing the { } for =>, the autobinding also
goes into place* and also only one expression is allowed, but the
"beggining" stays the same (that being function ($x)).

The function keyword also "collides" with the future scope with
multiple statements.

function ($x) use ($a, $b, $c) { $z = foo($a, $b); return $c($z, $x); }
function ($x) => { $z = foo($a, $b); return $c($z, $x); }

Now the possible confussion with the different scoping rules would be
even bigger, IMHO. (Disclaimer: I am huge fan of those autoimports and
think that without them, the RFC doesn't technically bring anything
important.)

Also, I'm not a fan of the "fn" prefix, because then you would have
two ways of writing "function", and people would probably want being
able to use "fn" for named functions as well, bringing inconsistency
into language. Also, this would requiring making "fn" a reserved word,
breaking some applications - wouldn't it?

Personally  I'd prefer the \ prefix you also mention as possible in
your RFC. It's also AFAIK used to denote lamba expression in another
languages already, so it might be familiar for some developers?

\(int $x) => $x * $y;
\() => foo()
\($x) => \($y) => \($z)

Yeah, this looks pretty nice.

Althought I'd honestly really prefer the Bob's syntax, but I
understand that you don't want to make some engine hacks to make it
working - but from userland developer's POV, that one was the best
(speaking as someone, who would use the syntax daily).

--

Regards
Pavel Kouřil

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

Reply via email to