Just throwing it in here while commuting, so it's a top-post with no references. Saw it yesterday on reddit (!!! Reddit being useful for once !!!): $callback = |$x| => $x ** 2;
On 31 Jan 2017 22:44, "Bob Weinand" <bobw...@hotmail.com> wrote: > > > Am 31.01.2017 um 19:41 schrieb Christoph M. Becker <cmbecke...@gmx.de>: > > > > On 31.01.2017 at 19:16, Michael Morris wrote: > > > >> On Tue, Jan 31, 2017 at 12:29 PM, Larry Garfield < > la...@garfieldtech.com> > >> wrote: > >> > >>> My question is why there's no mention of HHVM short closures, or the > >>> previous RFC to take that approach. See: > >>> > >>> https://docs.hhvm.com/hack/lambdas/introduction > >> > >> For what it's worth I'd rather look at > >> > >> array_map( $x ==> $x + 1); > >> > >> than > >> > >> array_map( fn($x) => $x + 1 ) > >> > >> Not to mention the former isn't a bc break. > > > > Neither is supposed to work, though. :) > > > > Anyhow, I'm not sure whether I'd prefer > > > > array_map($a, $b, $c ==> $a + $b + $c, $a1, $a2, $a3) > > > > over > > > > array_map(fn($a, $b, $c) => $a + $b + $c, $a1, $a2, $a3) > > > > or maybe > > > > array_map(fn $a, $b, $c => $a + $b + $c, $a1, $a2, $a3) > > > > Somehow, I tend to like a trailing keyword for better left-to-right > > readability. > > > > -- > > Christoph M. Becker > > The RFC states that we're needing some form of a prefix in order to avoid > implementing gigantic lexer hacks. > HHVM internally implements it by parsing some part of the syntax INSIDE > the lexer and then emitting a token before the first parameter to tell the > parser where a short Closure begins. > Having a normal terminal symbol easily allows the parser to detect short > Closures, without any hacks. > > It is just not a practical option from a technical point of view, and thus > not worth even considering. > > Bob