Re: [PATCH] [RFC] Closures and lambda functions in PHP
| From: | Rodrigo Saboya | Date: | Fri, 20 Jun 2008 16:27:05 +0000 |
| Subject: | Re: [PATCH] [RFC] Closures and lambda functions in PHP | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38478@lists.php.net to get a copy of this message | ||
Larry Garfield escreveu:
Totally silly idea: function foo($a, $b, &$c) global ($d, &$e) { // ... } $myfunc = lambda($a, $b, &$c) lexical ($d, &$e) { // ... } That puts all the information in the declaration line with parallel syntax and semantics, and would even allow both by-val and by-ref usage for both lexical and global values. The following would then be exactly equivalent functionality-wise: function foo() global (&$a) { // ... } function foo() { global $a; // ... } Is that too crazy an idea? --Larry GarfieldI think allowing globals/lexicals to be passed by value doesn't make much sense, you could just use a regular parameter for that. And that would bring another inconsistency to PHP, and would mean that PHP is discouraging the use of $_GLOBALS, that was created to discourage to use of 'global $var'. --Rodrigo Saboya