On Friday 20 June 2008, Lenar Lõhmus wrote: > Hi, > > Rodrigo Saboya wrote: > >> function ($x, $y) ($a, $b, $c) {}; > > > > This looks better > > > >> function ($x, $y) [$a, $b, $c] {}; > > I think this looks even better: > > function ($x, $y) use ($a, $b, &$c) {}; > > (one could use this syntax even for traditional functions to > use variable copies/references from global scope - just an idea). > > my 2, > L.
I am not sure if "use" is the clearest word to use there (wouldn't lexical there make more sense?), but I think the latter is a good trade-off. It makes it explicit whether you're using by-ref or by-val passing semantics, and the semantics and syntax are the same as for function parameters so there's a very low wtf factor. I still am not sure if re-using the "function" keyword is going to cause confusion, though, especially if what is being implemented becomes (as it seems like it may) effectively an alternate object syntax. As one of the Haskell list denizens commented, is there a potential for memory leakage if lambdas implicitly import $this when defined within an object method? Javascript makes it very easy to create memory leaks via closures if you're not very careful; I would be fine with requiring an explicit declaration of $this if it helped avoid memory leaks. (Even if not many people will use closures at first, I anticipate that they will become more widely used over time by which point arguments such as "they won't be used often enough for the memory issue to matter" will be false but it will be too late to fix. I don't think anyone has made that argument yet, but I'm trying to head it off before someone does. <g>) -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php