> On Mar 28, 2021, at 8:04 AM, Kalle Sommer Nielsen <ka...@php.net> wrote:
> 
> Den søn. 28. mar. 2021 kl. 14.30 skrev Deleu <deleu...@gmail.com>:
>> 
>> The fact that short closure is inconsistent with the rest of PHP is a done 
>> deal since the voting passed prior to 7.4 release. Unless there's a 
>> follow-up to deprecate the 7.4 short closure auto capture without `auto` 
>> keyword and make it look like PHP can't make up it's mind, I feel that your 
>> perspective doesn't match the proposed RFC. The RFC is extending short 
>> closure to support multiple statements and defining good semantics on how 
>> developers will interpret fn, => and {} throughout the language.
> 
> I think we have some sort of conundrum. I am not saying auto capture
> is not good semantics if that is what you are implying, I more than
> anyone would like consistency in the language but it is not a good
> language design to have two very similar features separated by a
> shorter keyword which implies totally different semantics. I don't
> find this a very intuitive way nor a good developer experience. I can
> understand that the connection of the `fn` keyword already having the
> meaning it has, but then we can bring up the side running RFC from
> Larry which proposes to make the same short syntax available for other
> function declarations, how would this work then with this mindset of
> `fn` meaning auto capture? Does that mean a procedural function
> declared with `fn` will now inherit the scope from which it was
> declared (usually the global scope)? What about methods declarations,
> do they import properties into the local scope? How does traits
> interact here, same as methods?
> 
> This is why I think having the `fn` being an alias of `function`
> neutralizes the argument of what happens for exactly those reasonings
> above, this allows arrow functions to continue being auto capture
> without any keyword.


I am curious how requiring developers to learn that "=>" means auto-capture and 
having developers question when they should choose "fn" instead of "function" 
when the answer is "it does not matter" is a more intuitive and a better 
developer experience than requiring developers to simply learn that "fn" means 
auto-capture?

-Mike

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

Reply via email to