Re: [RFC] Short syntax for anonymous functions

From: Date: Tue, 19 Feb 2013 16:09:08 +0000
Subject: Re: [RFC] Short syntax for anonymous functions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-65961@lists.php.net to get a copy of this message
There's already been an overwhelming negative reaction to this particular proposed syntax so I won't belabor the point much. In short, this is too similar to block statements and does have BC issues. -- IF (and I stress if) we add a a shorter anonymous function syntax I'd like it to be geared towards one-liners because that's where the current syntax feels really verbose, especially when you close over other variables: function ($n) use ($m) { return $m * $n; } Versus one potential option: ($value) |$m| => $m * $n; This syntax is short and expressive at the expense of clarity. Basically all short-syntax has that trade-off, so I am personally fine with it. The only other potential problem I see is parsing it; someone more familiar with PHP's parser would have to verify whether that would be a problem.

« previous php.internals (#65961) next »