Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38456 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17469 invoked from network); 20 Jun 2008 12:29:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2008 12:29:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 76.96.62.17 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.62.17 qmta10.westchester.pa.mail.comcast.net Received: from [76.96.62.17] ([76.96.62.17:48902] helo=QMTA10.westchester.pa.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/23-16112-8B2AB584 for ; Fri, 20 Jun 2008 08:29:45 -0400 Received: from OMTA12.westchester.pa.mail.comcast.net ([76.96.62.44]) by QMTA10.westchester.pa.mail.comcast.net with comcast id gAVy1Z0050xGWP85A09F00; Fri, 20 Jun 2008 12:29:42 +0000 Received: from earth.ufp ([24.13.255.226]) by OMTA12.westchester.pa.mail.comcast.net with comcast id gCVh1Z00R4trKQ83YCVit0; Fri, 20 Jun 2008 12:29:42 +0000 X-Authority-Analysis: v=1.0 c=1 a=IWnH0euKuzgA:10 a=K8k5FXa3V3kA:10 a=rKfwbIsRAYr87JM_qg8A:9 a=kPO6MPE-rZJuAP69dXYA:7 a=05Tj4BTmSZ_X7rR6GosxeVcWy9EA:4 a=FHBbIDN7CdwA:10 a=LY0hPdMaydYA:10 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id C1CCCD86F6 for ; Fri, 20 Jun 2008 07:29:41 -0500 (CDT) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qxhyNE0zEpdZ for ; Fri, 20 Jun 2008 07:29:41 -0500 (CDT) Received: from vulcan (unknown [192.168.42.1]) by earth.ufp (Postfix) with ESMTP id A9286D86EB for ; Fri, 20 Jun 2008 07:29:41 -0500 (CDT) To: internals@lists.php.net Date: Fri, 20 Jun 2008 07:29:40 -0500 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) References: <4856A547.3080801@gmx.net> <7E.CB.10717.56C7A584@pb1.pair.com> <485B5BCC.1060003@city.ee> In-Reply-To: <485B5BCC.1060003@city.ee> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-ID: <200806200729.40623.larry@garfieldtech.com> Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: larry@garfieldtech.com (Larry Garfield) On Friday 20 June 2008, Lenar L=C3=B5hmus 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= =20 there make more sense?), but I think the latter is a good trade-off. It=20 makes it explicit whether you're using by-ref or by-val passing semantics,= =20 and the semantics and syntax are the same as for function parameters so=20 there's a very low wtf factor. I still am not sure if re-using=20 the "function" keyword is going to cause confusion, though, especially if=20 what is being implemented becomes (as it seems like it may) effectively an= =20 alternate object syntax. =20 As one of the Haskell list denizens commented, is there a potential for mem= ory=20 leakage if lambdas implicitly import $this when defined within an object=20 method? Javascript makes it very easy to create memory leaks via closures = if=20 you're not very careful; I would be fine with requiring an explicit=20 declaration of $this if it helped avoid memory leaks. (Even if not many people will use closures at first, I anticipate that they= =20 will become more widely used over time by which point arguments such as "th= ey=20 won't be used often enough for the memory issue to matter" will be false bu= t=20 it will be too late to fix. I don't think anyone has made that argument ye= t,=20 but I'm trying to head it off before someone does. ) =2D-=20 Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of=20 exclusive property, it is the action of the thinking power called an idea,= =20 which an individual may exclusively possess as long as he keeps it to=20 himself; but the moment it is divulged, it forces itself into the possessio= n=20 of every one, and the receiver cannot dispossess himself of it." -- Thomas= =20 Jefferson