Re: Closure local return
| From: | Etienne Kneuss | Date: | Mon, 03 May 2010 13:33:05 +0000 |
| Subject: | Re: Closure local return | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48176@lists.php.net to get a copy of this message | ||
Hello,
On Mon, May 3, 2010 at 3:01 PM, mathieu.suen <mathieu.suen@easyflirt.com> wrote:
> Hi,
>
> The statement 'return' in a closure is now returning from the scope that
> evaluate the closure (evaluation scope).
> It could have been in an other way.
> It could mean return from the scope were the closure is create (define
> scope).
>
> May be it could be interesting to have a syntax for returning from the
> define scope.
> For example.
>
> $findedElment = $myList->selectIfAbsent($fooo, function(){
> return 'No item founded'; //Retrun from the define scope
> })
> //Do somthing with $findedElment
uh? Could you please provide a clear example of what you mean, in
contrast of how it works now.
"return" returns to just after the call, returning somewhere else
doesn't make much sense IMHO.
>
> So I am asking if there has been some discussion on it or if it could be
> added?
>
> Thanks
>
> --Mathieu Suen
>
>
>
>
--
Etienne Kneuss
http://www.colder.ch