Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38357 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61919 invoked from network); 18 Jun 2008 16:38:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2008 16:38:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=chris_se@gmx.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=chris_se@gmx.net; 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.5 (sometimes 2.4) (4) Received: from [213.165.64.20] ([213.165.64.20:51228] helo=mail.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/FB-03518-7E939584 for ; Wed, 18 Jun 2008 12:38:00 -0400 Received: (qmail invoked by alias); 18 Jun 2008 16:37:56 -0000 Received: from p54A174D0.dip.t-dialin.net (EHLO chris-se.dyndns.org) [84.161.116.208] by mail.gmx.net (mp019) with SMTP; 18 Jun 2008 18:37:56 +0200 X-Authenticated: #186999 X-Provags-ID: V01U2FsdGVkX1/xPJ5/E4bxmEaY0c/fJqB3WsCgUvkSeuhPLuNGY1 Ghp5xrNLfOrkzb Received: from [192.168.0.175] (HSI-KBW-091-089-005-213.hsi2.kabelbw.de [91.89.5.213]) by chris-se.dyndns.org (Postfix) with ESMTP id 4F9E3104E9 for ; Wed, 18 Jun 2008 18:27:23 +0200 (CEST) Message-ID: <485939B3.109@gmx.net> Date: Wed, 18 Jun 2008 18:37:07 +0200 User-Agent: Thunderbird 2.0.0.14 (X11/20080421) MIME-Version: 1.0 To: PHP Developers Mailing List References: <4856A547.3080801@gmx.net> <698DE66518E7CA45812BD18E807866CE01B11811@us-ex1.zend.net> <4859234C.5010003@zend.com> In-Reply-To: <4859234C.5010003@zend.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 Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: chris_se@gmx.net (Christian Seiler) Hi, [I'm going to collect here a bit:] Stanislav Malyshev wrote: > lexical in the proposal binds to creator's scope, not caller's scope, as > I understood. Anyway, binding to caller's immediate scope doesn't seem > that useful since you could just pass it as a parameter when calling. Correct and I completely agree. Chris Stockton wrote: > I am curious if is_callable will be able to detect these? Yes, as is call_user_func able to call them. (But as I was verifying that I saw that there was a tiny bug in the code that makes sure the internal names are not used directly, I will fix that.) Richard Quadling wrote: >> [JS Example] > I'm not sure I would say that there is a reference used there. > > I'm no expert, but x, f() and n are all working like normal variables with x > having to look outside of f(). > > Unless I'm getting confused with "pass by reference". Yes, shure, ok, it's not a reference in the classical sense BUT the effect is the same: A change INSIDE the closure changes the variable outside. The only useful way of doing that in PHP without rewriting the complete engine is using references - and such things are *already* done via references - namely global variables: If you import a variable via $global, in reality you are creating a reference to the actual global variable - global $foo is actually more or less the same as $foo =& $_GLOBALS['foo']. Regards, Christian