On Friday 20 June 2008, Stanislav Malyshev wrote:
> * A closure must be able to call itself recursively (via a
> higher-order function typically)
> [Check, since you can use variable you assigned closure to inside the
> closure, if I understand correctly]

This is a matter of implementation rather than design, so it should be 
resolved by testing rather than by reading the spec ;-)

> Well, I don't see any other way if you use references. Variables _are_
> mutable in PHP.

They are also copied by default (passed by value). So if lexical used copies 
by default (and passed objects by reference), it would be consistent with all 
of php except for global. Let global be the outcast and be consistent with 
exerything else. As long as references are easily available, I think this is 
the much better trade-off. And it makes water slightly cheaper than beer.

> I know function()() is weird

And would become weirder if foo(1)(2) is implemented. +1 to that by the way, 
allowing dereferencing for methods ( $obj->method1()->method2(); ) but not 
for functions is kinda mean.

Maybe function( ) [ ] { } instead of function( ) ( ) { }
That way the different parts actually look different. Also, confusion with 
arrays should be pretty much impossible here, both for the parser and human 
readers.

I prefer "lexical", though. Functional programming is not the default paradigm 
in PHP, so rather err on the side of explicitness.

Gesundheit
  Wag

-- 
Remember, growing older is mandatory. Growing up is optional.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to