Hi!
> Help me understand, b/c I am not clear what you mean by "we allow
> expressions in function calls". This is my immediate understanding of
> the anatomy of a closure:
Function call:
f($a, $b+$c);
Closure:
$x = function ($arg) use($a, $b+$c as $bplusc) {
/*...*/
}
For the same reason we don't want to write first case like this:
$dummyvar = $b+$c;
f($a, $dummyvar);
but actually allow doing $b+$c in the call, we might want to do the same
when we create a closure.
> Having an expression in use() is not immediately clear when that might
> execute, would it execute at declaration time? Or at call time? If the
Declaration time.
> That makes sense, but if you mean this:
>
> function do_something($foo->bar()) {}
Closure is a mix of two things - function and scope data. Function part
stays the same, the change proposed is for the scope data. Right now you
can import only variables as scope data, but I don't see why we can't
allow expressions too.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php