Re: [PATCH] [RFC] Closures and lambda functions in PHP
| From: | Alexander Wagner | Date: | Fri, 20 Jun 2008 14:33:08 +0000 |
| Subject: | Re: [PATCH] [RFC] Closures and lambda functions in PHP | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38467@lists.php.net to get a copy of this message | ||
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 its low WTF-factor.
Look like parameters. Behave like parameters.
Also, allowing this for regular function definitions might be a nice long-term
replacement for global.
> I would be fine with requiring an explicit declaration of $this if it helped
> avoid memory leaks.
I would propose to always require explicit declaration of $this, even if there
is no memory-leak problem. This would make it easier to distinguish plain
lambdas from closures and would prevent closures from being created by
accident.
As functional programming is foreign to most PHP-developers, better to err on
the side of being explicit.
Gesundheit
Wag
--
Her vocabulary was as bad as, like, whatever.