Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-27 Thread Alexander Wagner
On Friday 27 June 2008, Dmitry Stogov wrote: > 1) Fixed ref/noref issues Works for me. See attached test 11. Gesundheit Wag -- For sale: baby shoes, never worn. - flash fiction by Hemingway --TEST-- Closure test: Closure calls itself --SKIPIF-- --FILE-- --EXPECT-- 3 2 1 0 --TEST-- Closure

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-27 Thread Alexander Wagner
On Friday 27 June 2008, Andi Gutmans wrote: > I am not sure I like the idea of explicit $this. > [..] If we ever discover this is a huge issue Implicit unoptimized $this is never going to be a "huge issue", because it is not badly broken, only sublty. My crystal ball tells me that the following i

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-27 Thread Alexander Wagner
> Yes, you're right. My solution for this would be: I can't get this to work, it segfaults for me now when I try to use closures. Maybe I screwed something up, this is my first Zend-Engine-hackery. As you agree that the current behaviour is kinda weird, just put the fix in the next wave of patch

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-27 Thread Alexander Wagner
On Friday 27 June 2008, Andi Gutmans wrote: > I lean towards the use(...) syntax. Me too. > > * I provided a patch variant that only stores $this if $this is > > explicitely used inside a closure [..] > > Safest not to take shortcuts. You get yourself into trouble with things > which will s

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-26 Thread Alexander Wagner
> * I added tests (Zend/tests/closures_*.phpt) that ensure the correct > behaviour of closures. I'd like to propose an additional test to ensure closures can all themselves: Expected output: 3 2 1 3 I see exactly one problem with the patch, which is that the above script shouldn't work wi

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-20 Thread Alexander Wagner
> I think allowing globals/lexicals to be passed by value doesn't make > much sense, you could just use a regular parameter for that. No, that is highly inconvenient when you're doing actual functional programming with higher order functions and everything. $i = 1; $incrementor = lambda ($x) lex

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-20 Thread Alexander Wagner
On Friday 20 June 2008, Chris Stockton wrote: > No one at all thinks: > function foo($x, $y) use $a, $b, $c { > } > > Looks awkward and a little out of place It certainly is new and different in PHP, but I don't see a reason why this should be hard to get used to. Also, it works for Java exceptio

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-20 Thread Alexander Wagner
On Friday 20 June 2008, Larry Garfield wrote: > > function ($x, $y) use ($a, $b, &$c) {}; > > I am not sure if "use" is the clearest word to use there (wouldn't lexical > there make more sense?) I agree. "use" for both namespaces and closures may not be a good idea. Otherwise +1 to this syntax for

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-19 Thread Alexander Wagner
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

Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP

2008-06-19 Thread Alexander Wagner
First, a comment from haskell-land: http://www.haskell.org/pipermail/haskell-cafe/2008-June/044533.html http://www.haskell.org/pipermail/haskell-cafe/2008-June/thread.html#44379 On Wednesday 18 June 2008, Christian Seiler wrote: > Frankly, I don't really see a problem with using references. It fit