Re: [RFC]Discuss] Syntax for Arrow Functions
| From: | Levi Morrison | Date: | Tue, 30 May 2017 18:49:15 +0000 |
| Subject: | Re: [RFC]Discuss] Syntax for Arrow Functions | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-99278@lists.php.net to get a copy of this message | ||
>> You mentioned ability to explicitly specify binding as a possible extension.
>> However
>>
>> [$var1, $var2]()
>>
>> is not necessarily failing right now, it may be a valid array callable.
>>
>> Nikita
>
> As already mentioned we must maintain a leading
= or
> &:
>
> [=, $var1, $var2]()
> [=, $var1, $var2]()
>
> Sorry if that was unclear.
Oops, forgot to change the bottom line:
[=, $var1, $var2]()
[&, $var1, $var2]()
The first line means "bind any implicit usages of variables by value,
and also bind $var1 and $var2 by value".
The second line means "bind any implicit usages of variables by
reference, and bind $var1 and $var2 by value".
This exists in C++ but C++ allows you to drop the leading = or &.
We cannot, for precisely the reason you mentioned.