Re: [RFC] Closures, Lambdas and use
| From: | Greg Beaver | Date: | Wed, 21 Jan 2009 17:12:59 +0000 |
| Subject: | Re: [RFC] Closures, Lambdas and use | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42754@lists.php.net to get a copy of this message | ||
Dmitry Stogov wrote:
> Personally I like the current syntax more and don't see any reason to
> change it.
>
> Thanks. Dmitry.
>
> Marcus Boerger wrote:
>> Hello Internals, Dmitry, Lukas, Johannes,
>>
>> some time back (August 08) I complained about 'use' being at a weird
>> position and not at the same place as 'global' or 'static' where I
>> expected it. Back then Dmitry asked me to provide a patch to check out
>> the alternative. Now during the holidys I finally found some time to
>> change from:
>> $f = function() use ($x) {}
>> to:
>> $f = function() { use $x; }
>>
>> Patch is attached.
>>
>> Comments?
I think the current syntax may be clearer:
<?php
namespace blah;
include 'file/with/foo/namespace.php';
use foo/something;
$f = function() use ($x) {}
?>
<?php
namespace blah;
include 'file/with/foo/namespace.php';
use foo/something;
$f = function()
{
use $x;
}
?>
The second version requires a visual re-parsing, the first is clear at a
glance. In addition, if support for namespaced variables was ever
introduced, confusion would abound.
Thanks,
Greg
P.S. happy new year (I'm a bit slow)