Hello Larry,
Sunday, January 4, 2009, 10:05:25 PM, you wrote:
> On Sunday 04 January 2009 10:45:30 am Sebastian Bergmann wrote:
>> Marcus Boerger schrieb:
>> > $f = function() { use $x; }
>>
>> +1 for consistency.
> +1 for consistency as well, which is why, as I recall, that syntax was
> rejected.
> $f = function() {
> global $x; // By reference.
> use $y; // By value or by reference?
> }
> If $y is by reference by default there was no obvious way to make it by value.
> If by value, then it is inconsistent with the behavior of global, which is by
> reference. It was determined that we definitely needed to be able to allow
> both by value and by reference.
> $f = function() use ($y, &$z) {
> global $x; // By reference
> }
> $y is clearly by value, and $z clearly by reference, as that parallels the way
> function parameters work right next to the lexical variables.
> The way to increase consistency would be to allow the opposite:
And then what do we do with static? And besides how is:
...use (&$ref)
different from:
...use &$ref;
But maybe you want consistency by breaking nearly every PHP script ever
written? Or did I miss some Months and it is early April rather than early
January?
> $f = function($a, &$b) use ($y, &$z) global ($x, &$w) {
> }
> $x is pulled from global scope by value.
> $w is pulled from global scope by reference.
> $y is pulled from lexical scope by value.
> $z is pulled from lexical scope by reference.
> $a is pulled from calling scope by value.
> $b is pulled from calling scope by reference.
> Right now we have everything there except the global param list. I don't know
> if we want to bother adding that in 5.3 at this point (as it would be a
> syntax/feature change), but IMO that is the best way to improve consistency
> while getting a little extra functionality (global by value) at the same time.
> --
> Larry Garfield
> [email protected]
Best regards,
Marcus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php