Re: [RFC] Allow "use( $longname as $alias)" syntax for closures declaration
| From: | Stas Malyshev | Date: | Fri, 13 Apr 2012 05:02:11 +0000 |
| Subject: | Re: [RFC] Allow "use( $longname as $alias)" syntax for closures declaration | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-59851@lists.php.net to get a copy of this message | ||
Hi!
> To me it's not about renaming variables, but rather avoiding to clutter
> the parent scope with variables, e.g.:
>
> $closure = function () use ($this->getFooBar() as $foo) {
> $foo->stuff();
> }
>
That sounds like an interesting idea. If it can be done properly (i.e.,
what if that expression throws exception or produces error? We need to
be careful not to leave the engine in weird state there) that may be nice.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227