Hi!

> What's proposed is really more closely related to the functionality of 
> "global" since you're taking a non-local variable and making it accessible.

It is like global but with important difference - global inserts the
variable into current scope, with all consequences (modification, etc.).
Proposed use statement imports variable or expression into the context,
but (usually) does not influence the parent scope at all.

> Is the shorthand version of this:
> 
>    $foo = 5;
>    $bar = $foo;
>    $baz = function () use ($bar) {
>      // use $bar somehow
>    }
> 
> And with that example, I see this making less sense.  The thing is that 

For variables, it's not very useful. For expressions, might allow to
avoid some boilerplate code - for the same reason we allow expressions
in function calls - we might ban that, and have people assign
expressions to variables and then use variables for function calls, but
we recognize it is not nice.

> $fileReturnsFunction and that would work too).  So, if that was a bad 
> variable name 2 lines earlier, why not just change the variable name for 
> both scopes?

It's not about variable names, as I see it. Just renaming is not very
useful. Having expression there is useful, for the reason described above.
-- 
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

Reply via email to