I'm at a bit of a loss as to why Laruence is claiming that allowing closures to implicitly access variables in the outer scope requires duplicating the symbol table.
Is there any technical reason why it's not possible for scopes to retain a pointer to their parent scopes so variables can be looked up that way? On Apr 13, 2012 6:20 PM, "Yasuo Ohgaki" <yohg...@ohgaki.net> wrote: > Hi, > > 2012/4/13 Verbitsky Alexander <verbitsky_alexa...@mail.by>: > > On 04/12/2012 06:38 PM, Laruence wrote: > >> > >> Hi: > >> I have made a RFC to allow user use T_AS in the closure > declaration, > >> like: > >> > >> function () use($long as $l,&$long as $r) { > >> > >> } > >> > >> here is the RFC: https://wiki.php.net/rfc/useas > >> > >> any ideas? thanks > >> > > Closure is a functional literal that can pull with itself all variables > > visible in current scope where it was created. For my opinion using > keyword > > 'use' is not necessary and i would have removed it. If you need different > > name of variable maybe you need anonymous function. > > > > You might be used to other language's scoping, but > this is the way PHP works. > > Named function cannot do this, but anyway > function FUNC($a, $b, $c) uses ($d, $e, $f) {} > is like > function FUNC($a, $b, $c) { global $d, $e, $f; } > > I would rather have this. > function FUNC($a, $b, $c) uses ($d, $e, $f) {} > Then it would be consistent with anonymous function. > > There are methods, so we should be careful though. > > Regards, > > -- > Yasuo Ohgaki > yohg...@ohgaki.net > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >