Re: [PHP-DEV] [RFC] Arrow functions / short closures

This is only part of a thread. view whole thread
  104697
March 13, 2019 20:37 chasepeeler@gmail.com (Chase Peeler)
On Wed, Mar 13, 2019 at 4:26 PM Travis van der Font font@gmail.com>
wrote:

> Arrow functions are ternary operators to functions. > While they are nice and shorten, they can be hard to read at times; > considerably to people who aren't used to them which is surprisedly a > majority of PHP programmers. > > Having them optional sure, but not necessary. > > Feel free to decide between fn() or f() as both are equivalently > comprehensible to the same level of minimalism. > Anyone considered? ($x) => $x * $multiplier > > I use this format a lot in javascript, so I like not having any indicator.. I can't remember which language it was, but they didn't even require the
parentheses if there was only a single input: $x => $x * $multiplier;
> #mytwocents > > Kind regards / Léif Gréiss, > Travis van Font > > > Le mer. 13 mars 2019 à 16:57, Nikita Popov ppv@gmail.com> a écrit > : > > > Hi internals, > > > > 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 > > > > This is based on a previous (withdrawn) proposal by Levi & Bob. It uses > the > > syntax > > > > fn($x) => $x * $multiplier > > > > and implicit by-value variable binding. This example is roughly > equivalent > > to: > > > > function($x) use($multiplier) { return $x * $multiplier; } > > > > The RFC contains a detailed discussion of syntax choices and binding > modes. > > > > Regards, > > Nikita > > > --
-- Chase chasepeeler@gmail.com
  104699
March 13, 2019 20:56 rowan.collins@gmail.com (Rowan Collins)
On 13/03/2019 20:37, Chase Peeler wrote:
>> Anyone considered? ($x) => $x * $multiplier >> >> I use this format a lot in javascript, so I like not having any indicator. > I can't remember which language it was, but they didn't even require the > parentheses if there was only a single input: > $x => $x * $multiplier;
I suggest you both read the RFC; about half the page is dedicated to summarising the syntaxes which have been considered, and the pros and cons of each. The summary of that syntax begins: > This is both the most popular and the most technically infeasible syntax. Regards, -- Rowan Collins [IMSoP]
  104700
March 13, 2019 21:06 ben@benramsey.com (Ben Ramsey)
> On Mar 13, 2019, at 15:56, Rowan Collins collins@gmail.com> wrote: > > I suggest you both read the RFC; about half the page is dedicated to summarising the syntaxes which have been considered, and the pros and cons of each. > > The summary of that syntax begins: > > > This is both the most popular and the most technically infeasible syntax.
I did read the RFC, and I could find no mention of f(), so I’ll rephrase my question. :-) I would like to consider `f` as a potential leading symbol instead of `fn`. Cheers, Ben