On 2/3/2017 11:26 PM, Michael Morris wrote:
> On Fri, Feb 3, 2017 at 3:37 PM, Niklas Keller <m...@kelunik.com> wrote:
>>
>>
>> There are more drawbacks to that syntax like no parameters looking pretty
>> weird: || =>
>>
>>
> I can't think of a valid example of an arrow function without any arguments
> at all. These functions are very simple iterators to plug into things like
> array_map. If you can think of one please post it.
> 

There are many situations where one might want a closure that takes no
arguments.

```
$option->unwrapOrThrow(|| => new Exception('my message'));
```

Creating a supplier callable is often less resource intensive than
actually computing the supplied value.

Rust has exactly that syntax but it can become rather cryptic and PHP is
a verbose language in general. I think that it is best for PHP to go for
`function` to keep things nicely aligned and to avoid problems with
union types (which we really need).

-- 
Richard "Fleshgrinder" Fussenegger

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to