On Fri, Sep 25, 2015 at 9:44 PM, Bishop Bettini <bis...@php.net> wrote: > Hi, > > On Mon, Sep 21, 2015 at 9:59 PM, Bob Weinand <bobw...@hotmail.com> wrote: > >> So, before I start the vote, just two quick notes: >> I've added two notes about the statement syntax and the single variable >> use. >> Though a few people complained, I'm not switching to the ==> operator, as >> I noticed many people expected typehints to work (they don't due to parser >> limitations) when they compared to Hack's short Closures. It also allows us >> to differ syntax-wise [e.g. for typehints] from Hack without causing any >> confusion later. Which should be the smartest choice: Avoid conflicts. (If >> anyone strongly feels against that, he may vote no, but I would like to not >> bikeshed that in this Vote thread, but leave it free for eventual actual >> issues.) >> > > I voted "no" because I'm against the automatic use () and introducing a new > symbol. > > An earlier short closure RFC [1] supports explicit import, and I would want > to see explicit import mandated. And rather than inventing a new symbol, > why not just re-purpose 'as' in this context? > > function sumEventScores($events, $scores) { > $types = array_map($event as $event['type'], $events); > return array_reduce($types, ($sum, $type) as $sum + $scores[$type]); > } > > 'use' is already purposed in three places, I don't see why 'as' can't also > be in three places. Though I've not checked the engine source to see the > actual effort, so this just may be astronaut architecting. > > Anyway, thanks to Bob for his hard work pulling this together and everyone > for arguing it out. That's what makes PHP great. > > Sincerely, > bishop > > [1]: https://wiki.php.net/rfc/short-syntax-for-anonymous-function
Hello, I can't grasp the "intent" behind the "as". Reading it like "parameter $sum and parameter type as $sum + $scores[$type]" seems pretty confusing to me. Also, if we look at the example from RFC - with your "as" suggestion, it would look like this: function reduce(callable $fn) { return $initial as $input as { $accumulator = $initial; foreach ($input as $value) { $accumulator = $fn($accumulator, $value); } return $accumulator; }; } This doesn't seem like the right way to me. :( Regards Pavel Kouřil -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php