Re: [RFC]Discuss] Syntax for Arrow Functions

From: Date: Wed, 31 May 2017 14:11:12 +0000
Subject: Re: [RFC]Discuss] Syntax for Arrow Functions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-99298@lists.php.net to get a copy of this message
On 31 May 2017 14:48:03 BST, Levi Morrison <levim@php.net> wrote: >On Wed, May 31, 2017 at 7:36 AM, Rowan Collins ><rowan.collins@gmail.com> wrote: >> I was just pondering alternative approaches to stop the => token >being ambiguous, and wondered if surrounding the whole expression with >braces could work: >> >> { => $bound * 2 } >> { $a, $b => $a * $b } > >This does not work. We permit expressions as statements and we also >allow empty blocks: > > { > $a = $foo; > } > >These will conflict in the grammar. Yeah, I wondered if that would be the case, but don't know enough about how parsers work to be sure one way or the other. It's not ambiguous, because the => wouldn't be legal there, but I guess it's "too late" by the time that token is reached. :( Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#99298) next »