Re: [RFC] Allow "use( $longname as $alias)" syntax for closures declaration

From: Date: Thu, 12 Apr 2012 18:06:25 +0000
Subject: Re: [RFC] Allow "use( $longname as $alias)" syntax for closures declaration
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-59802@lists.php.net to get a copy of this message
On Thu, Apr 12, 2012 at 7:38 PM, Robert Williams <rewilliams@thesba.com> wrote: > Also, remember that the closure is in fact another function, a function > that performs its own actions independent of the parent. Just as other > functions can pick whatever parameter names make the most sense to them > internally, I think it makes sense to allow closures to pick whatever > used-variables names make the most sense to them internally. It's > certainly not a requirement, but used judiciously, I think it can > definitely lead to easier-to-read (i.e., easier-to-maintain) code since it > means variables can be named to best reflect their usage in both parents > and closures. Thanks, this is convincing. The only thing I'm not really sure about then is whether it is a good idea to allow importing $this using an alias. As $this is already available by default I don't see much point in allowing it. It's somewhere between useless and confusion. Nikita

« previous php.internals (#59802) next »