This makes me thinking, has this syntax been considered?

($x) => { $x * $y }

Nested:

($x) => { ($y) => { $x * $y } }

AFAICS, we don't need the brackets around the whole expression, as this
should be parsable without any ambiguity; and the syntax would be closer to
that of JavaScript.


On Thu, 14 Mar 2019 at 14:44, Rowan Collins <rowan.coll...@gmail.com> wrote:

> On 13 March 2019 15:56:40 GMT+00:00, Nikita Popov <nikita....@gmail.com>
> wrote:
> >Motivated by the recent list comprehensions RFC, I think it's time we
> >took
> >another look at short closures:
> >
> >https://wiki.php.net/rfc/arrow_functions_v2
>
> Hi Nikita,
>
> Thanks for reviving this. I think the RFC does a great job of
> justifying both the syntax and the behaviour, and focusing on the most
> used features without ruling out further additions in future. In
> particular, I think whether and how we support auto-capture in full
> function bodies has its own pros and cons to debate, separate from
> auto-capture as a convenience in short "lambda" expressions.
>
> I was initially quite drawn to a block-style syntax. As someone not
> particularly familiar with functional programming (which I suspect
> puts me in the majority of PHP users), I actually find it easier to
> spot this as "a closure returning a closure":
>
> { ($x) => { ($y) => $x * $y } }
>
> rather than having to work out the associativity of chained operators:
>
> fn($x) => fn($y) => $x * $y
>
> However, I imagine the only people who will heavily use such a
> construct will be those who *are* familiar with functional programming
> in other languages, and will find the simpler syntax more familiar and
> convenient.
>
> It would also be ugly to add full block bodies in a similar style like
> { ($x) => { ... } }, and while I'm not convinced we need that, we
> probably don't want to rule it out completely.
>
> As such, I support the RFC in its current form.
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to