Re: [RFC]Discuss] Syntax for Arrow Functions

From: Date: Mon, 05 Jun 2017 18:06:03 +0000
Subject: Re: [RFC]Discuss] Syntax for Arrow Functions
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-99368@lists.php.net to get a copy of this message
On 6/5/2017 7:55 PM, Rowan Collins wrote: > I think it's not just a case of implementation problems, it's actually ambiguous with > current syntax: > > $foo = array( ($x) => 42 ); > > Sure, those inner brackets are redundant, so it's not likely to break much actual code, > but it's kind of weird to have this one case magically turn into a closure, when anything else > you put in those brackets would just be used as the array key: > > $foo = array( f($x) => 42 ); > $foo = array( ($x+1) => 42 ); > $foo = array( (42) => $x ); > $foo = array( (X) => 42 ); > $foo = array( ($x) => 42 ); > $foo = array( ("$x") => 42 ); > > Even if we could teach the parser to understand it, I'd personally be against it for the > difficulty of *humans* parsing it. I find shorthand closures hard enough to read anyway, especially > when people suggest things like ($x) => ($y) => $x * $y * $z; > > Regards, > Ah thanks, yeah, that was the problem. At trivago we have such a super fancy ES6 code base where everything is done in a super cryptic syntax, so that absolutely nobody who is not used to reading this all day has a chance to understand a single thing. So, yeah, I completely agree with you on everything. That being said, they are handy if not overused, like so many features. :) The pipes should still be in the game. $foo = array( |$x| => 42 ); -- Richard "Fleshgrinder" Fussenegger

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#99368) next »