Hi Aaron,
Sent from my iPhone > On 4 Feb 2017, at 10:33, Aaron Piotrowski <aa...@trowski.com> wrote: > > >> On Feb 3, 2017, at 9:06 PM, Stephen Reay <php-li...@koalephant.com> wrote: >> >> >>> On 4 Feb 2017, at 07:25, Aaron Piotrowski <aa...@trowski.com> wrote: >>> >>> $callback = |int|float $x| => $x ** 2; >> >> Forget the parser, you're giving my eyes diabetes trying to read that. > > I absolutely agree that it's terrible… the point is that types (even > potential future union types) can be used with short closures, but it > certainly doesn't mean they should be. I don't think confusion with a > non-existent and non-recommended way of coding should be a reason against a > particular syntax. Using type hints is a part of the language. It even has benefits that I can absolutely see being used here: array_map(function(Foo $x) => $x->bar()); If Foo is a class/interface with a method of bar, your IDE can know that it's a valid method to call. That of course is in addition to the benefit of getting useful type errors from PHP itself. > >> As has been said before, PHP is relatively verbose compared to other >> languages. That makes it slightly more characters to type, but it also makes >> it absolutely clear what is happening. > > Using `function` IMO makes it more likely to confuse a short closure with a > regular closure. Reusing the `function` keyword with different semantics may > result in some confusion. > So we should instead use syntax already used for bit wise OR, and further confuse the situation when the function has no parameters and reusing the logical OR operator. Brilliant. This is still a function, it has slightly different semantics, just like how a regular function, a class instance method and a static class method have slightly different semantics: we still use the function keyword for all of those. The static keyword is used for functions, class static properties, static variables and even static closures: it's semantics are slightly different for each case but we reuse the same keyword. >> As Niklas said, all ambiguity/clarity issues are solved by using "function", >> at the cost of 6 characters. >> >> Suggesting that a search for arrow functions will be easier with <insert >> random character here> and then using grep (which could also easily match >> arrow functions using "function") as your example search seems odd to me. > > I never suggested this, Björn Larsson did. Any of the possibilities mentioned > in this thread could easily be searched. Apologies I meant to quote the earlier message/author but I'm on a phone and forgot to do so. I didn't mean to imply this was your view. Cheers Stephen > > Regards, Aaron Piotrowski > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php