rfc:short-syntax-for-anonymous-function

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:short-syntax-for-anonymous-function [2013/02/19 12:47] – created mdrfc:short-syntax-for-anonymous-function [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Request for Comments: Short syntax for anonymous functions ====== ====== Request for Comments: Short syntax for anonymous functions ======
   * Version: 1.0   * Version: 1.0
-  * Date: 2008-03-06+  * Date: 2013-02-19
   * Author: Marcello Duarte <marcello.duarte@gmail.com>   * Author: Marcello Duarte <marcello.duarte@gmail.com>
   * Status: Draft   * Status: Draft
-  * First Published at: https://wiki.php.net/rfc/short-syntax-for-closures+  * First Published at: https://wiki.php.net/rfc/short-syntax-for-anonymous-function
   * Other formats ..   * Other formats ..
  
Line 27: Line 27:
 </code> </code>
  
-===== Passing an anonymous function to a function =====+==== Passing an anonymous function to a function ====
  
 The syntax allows for a cleaner way to pass a an anonymous function around. The syntax allows for a cleaner way to pass a an anonymous function around.
Line 40: Line 40:
 </code> </code>
  
 +==== Adding variables to the function scope ====
 +
 +<code php>
 +<?php
 +
 +setFormattingStrategy({$string use $filter =>
 +    return $filter->trimedAndLowerCase($string));
 +});
 +
 +</code>
 ===== What is common use cases in other language ===== ===== What is common use cases in other language =====
 ==== Building domain specific languages ==== ==== Building domain specific languages ====
Line 52: Line 62:
  
 function it($testName, callable $test) { function it($testName, callable $test) {
-    print("    $test" . PHP_EOL);+    print("    $testName" . PHP_EOL);
     $test();     $test();
 } }
rfc/short-syntax-for-anonymous-function.1361278069.txt.gz · Last modified: 2017/09/22 13:28 (external edit)