Re: [RFC] Short-function syntax

From: Date: Wed, 21 Oct 2020 22:59:41 +0000
Subject: Re: [RFC] Short-function syntax
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-112099@lists.php.net to get a copy of this message
On Wed, Oct 21, 2020, at 5:17 PM, Rowan Tommins wrote: > It occurred to me recently that maybe we could make "function" and "fn" > synonyms everywhere, i.e. make both "$double = function($x) => $x *2;" > and "$double = fn($x) use ($x) { return $x *2; };" valid. I'm not sure > if that's desirable, or even if there's a reason it can't be done, but > it would mean you don't have to make a decision on this RFC... Sara mentioned that as well. I can see the appeal, but at the same time I foresee that leading to a question about when to use which, divergent coding standards with different people doing it differently and different projects eventually adopting different standards, eventually a PSR that attempts to standardize it, probably by proposing the same "when it's a short-function of some kind" rule, and only some projects adopt it. Basically, a mess. Whatever we do, it should be language-consistent so that there's no bikeshed potential. --Larry Garfield

« previous php.internals (#112099) next »