Re: [RFC] [Discussion] Short Closures
| From: | Björn Larsson | Date: | Thu, 10 Sep 2015 21:15:55 +0000 |
| Subject: | Re: [RFC] [Discussion] Short Closures | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88149@lists.php.net to get a copy of this message | ||
Den 2015-09-10 kl. 22:22, skrev Bob Weinand:
should be there or not. So one more thing to not think about... Anyway, I noticed that both C# and Hack uses lamda functions for asynchronous programming, so good to get going with this RFC! Hack example: |async (int $x, string $y): Awaitable<Foo> ==> await $x->genFoo($y, $z); //Björn |Am 10.09.2015 um 22:04 schrieb Björn Larsson <bjorn.x.larsson@telia.com>: Den 2015-09-03 kl. 00:48, skrev Rowan Collins:You are probably just very familiar with them ;-) It totally isn't unusual to have that (for languages allowing untyped params), see: Javascript (ES6) Hack C# (There probably are more, I just can recall these three off my head) So, I think this very much falls under personal preference. Bob Yes, for me it's about not needing to think whether parenthesisAmendment 3. Make the parentheses around the argument list mandatory so that (if Amendment 1 is also adopted) there is only a single variant of the syntax, namely "( param list ) ~> expression".Any plans to incorporate any of the amendments above in the RFC? Personally I favour amendment 3. One of your examples would be: functionreduce(callable $fn){ return($initial)~>($input)~>{$accumulator=$initial; foreach($inputas$value){ $accumulator=$fn($accumulator,$value); } return$accumulator;};} Or maybe I'm just overly familiar having function arguments within parenthesis ;) Regards, //Björn Larsson