Hey Christian, Nice job!
More below: > -----Original Message----- > From: Christian Seiler [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 26, 2008 9:24 AM > To: Dmitry Stogov > Cc: php-dev List; Andi Gutmans; Stas Malyshev > Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP > -snip- > > * Lexical vars are now copied instead of referenced by default. Using > & in front of the var, the behaviour may be changed. I added that in > order to demonstrate that both was possible and that a simply change > of grammar suffices. In my eyes this is the main issue where a > discussion has to take place (i.e. copy or reference by default? > possibility to change default via syntax? which lexical syntax?) > before the proposal can be accepted. I think doing this mixed approach is the right one, i.e. $var1, &$var2. It delivers choice and adds clarity as it's explicit about value vs. reference. > * I provided patches for both lexical $var and use ($var) syntaxes. I lean towards the use(...) syntax. > * I provided a patch variant that only stores $this if $this is > explicitely used inside a closure (or a nested closure of that > closure). This works since it is possible to detect whether $this > is used at compile time. For this, I have added a this_used flag > to the op_array structure. Safest not to take shortcuts. You get yourself into trouble with things which will stop working. -1 on this optimization. > * I added tests (Zend/tests/closures_*.phpt) that ensure the correct > behaviour of closures. Excellent. > Anyway, feel free to discuss. > > In my eyes, the following questions should be answered: > > * Do you want closures in PHP? I think most people here feel it's useful or are at least indifferent. > * Do you want closures in PHP 5.3? I really think we need to get the release process for 5.3 going so I suggest to do it for the following minor version and commit it to PHP 6. Andi