Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39260 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91449 invoked from network); 24 Jul 2008 09:24:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2008 09:24:57 -0000 Authentication-Results: pb1.pair.com header.from=chris_se@gmx.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=chris_se@gmx.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.net designates 213.165.64.20 as permitted sender) X-PHP-List-Original-Sender: chris_se@gmx.net X-Host-Fingerprint: 213.165.64.20 mail.gmx.net Linux 2.6 Received: from [213.165.64.20] ([213.165.64.20:47074] helo=mail.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/A8-44225-86A48884 for ; Thu, 24 Jul 2008 05:24:57 -0400 Received: (qmail invoked by alias); 24 Jul 2008 09:24:53 -0000 Received: from p54A17F89.dip.t-dialin.net (EHLO chris-se.dyndns.org) [84.161.127.137] by mail.gmx.net (mp021) with SMTP; 24 Jul 2008 11:24:53 +0200 X-Authenticated: #186999 X-Provags-ID: V01U2FsdGVkX19TtQl9SO1T2QVIuZ3hlzWYtT8qG3kFeiJDDXP/ly nbsutPoeW7TaSx Received: from [192.168.100.13] (cobalt.seiler.lan [192.168.100.13]) by chris-se.dyndns.org (Postfix) with ESMTP id 50D0719596; Thu, 24 Jul 2008 10:52:00 +0200 (CEST) Message-ID: <48884A13.1050700@gmx.net> Date: Thu, 24 Jul 2008 11:23:31 +0200 User-Agent: Thunderbird 2.0.0.14 (X11/20080421) MIME-Version: 1.0 To: George Antoniadis CC: internals@lists.php.net References: <641f88250807231422x53d5475t3c665524045b4e6@mail.gmail.com> In-Reply-To: <641f88250807231422x53d5475t3c665524045b4e6@mail.gmail.com> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.6899999999999999 Subject: Re: [PHP-DEV] Php 5.3 Snap - Lambda functions and $this scope From: chris_se@gmx.net (Christian Seiler) Hi, > Wouldn't it be better (and maybe safer) to allow the use of $this as a > closure instead of passing it to the new lambda function? We had that in a previous patch. We had quite a few discussions on what the best syntax would be, actually. In the end, Dmitry and I chose to implement it in this way because it seemed more consistent with current PHP behaviour and because more people on internals seemed to like it than dislike it. As for the consistency with current PHP behaviour: $this is always present in any class method which is non-static. Every other variable (except superglobals) used in a method or function must explicitly be defined - either as a parameter, or in the function or via 'global $foo'. So $this is already special. So using the presence or absence of the 'static' keyword in front of the 'function' keyword to determine whether $this is available inside the closure seems much more natural. Of course, there will be people who disagree with this. But we've already discussed closure syntax quite a bit while discussion my original patch and I believe the compromise we've reached is quite acceptable for everybody. Regards, Christian