Edit report at http://bugs.php.net/bug.php?id=54243&edit=1
ID: 54243 User updated by: anil at saog dot net Reported by: anil at saog dot net Summary: Shorter syntax for closures Status: Open Type: Feature/Change Request -Package: Scripting Engine problem +Package: *General Issues -Operating System: +Operating System: * PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Changed package Previous Comments: ------------------------------------------------------------------------ [2011-03-13 16:09:36] anil at saog dot net Description: ------------ Current closure syntax makes the code a little bit unreadable and also shortening the syntax of a handy thing like this seems more logical. Test script: --------------- As of now "closure" syntax is: function ($a) use($b){ return $a == $b; } Passing a closure to any other scope: $myObject = new myObject (); $myObject->MyMethod('abc', function ($a) use($b){ return $a == $b; }); Expected result: ---------------- My short syntax candidate is: $([arg1],[arg2],[arg...], {[method body]}, [scope_var1],[scope_var2],[scope_var...]) So passing with use token syntax: $myObject = new myObject (); $myObject->MyMethod('abc', $($a, {$a == $b}, $b)); Without "use" token: $myObject = new myObject (); $myObject->MyMethod('abc', $($a, {$a == $b})); With more than one method argument: $myObject = new myObject (); $myObject->MyMethod('abc', $($a,$k,$p,{$a == $b})); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54243&edit=1