Re: [RFC] Allow "use( $longname as $alias)" syntax for closures declaration
| From: | Xinchen Hui | Date: | Fri, 13 Apr 2012 00:05:39 +0000 |
| Subject: | Re: [RFC] Allow "use( $longname as $alias)" syntax for closures declaration | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-59818@lists.php.net to get a copy of this message | ||
Sent from my iPad
在 2012-4-13,2:07,Nikita Popov <nikita.ppv@googlemail.com> 写道:
> 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.
And also consistent, you can use for each as, use namespace as, why
not closure use?
I can not understand why you think it,s useless and confusion? Can
you give me a example?
Thanks
>
> Nikita
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>