Re: [RFC] Short syntax for anonymous functions

From: Date: Tue, 19 Feb 2013 17:03:34 +0000
Subject: Re: [RFC] Short syntax for anonymous functions
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-65970@lists.php.net to get a copy of this message
On Tue, Feb 19, 2013 at 6:40 PM, Levi Morrison <morrison.levi@gmail.com>wrote: > > Say we agree on the syntax above > >> ($n) |$m| => $m * $n; > > What happens when my one liner function needs to do one more operation > > like checking the value of $n before multiplication? > > As I stated before suggesting the syntax: It's only meant for a single > expression. It's purposefully NOT intended to cover multiple > expressions. In that case the current (verbose) syntax is better for > all criteria I care about. Additionally, neither Python nor Dart > allows multiple expressions in their short-syntax functions. > > +1 A similar syntax was applied in C# lambads. For example : m => m * n. Though C# allows to use code block in lambdas, I do think that we should focus on one-expression only, since the current callbacks syntax (function() { }) is great, I believe, for multiline code. > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#65970) next »