Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28431 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3739 invoked by uid 1010); 19 Mar 2007 18:31:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 3724 invoked from network); 19 Mar 2007 18:31:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2007 18:31:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=sean@caedmon.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sean@caedmon.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain caedmon.net from 69.60.120.90 cause and error) X-PHP-List-Original-Sender: sean@caedmon.net X-Host-Fingerprint: 69.60.120.90 iconoclast.caedmon.net Linux 2.4/2.6 Received: from [69.60.120.90] ([69.60.120.90:42002] helo=iconoclast.caedmon.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/14-01604-3F6DEF54 for ; Mon, 19 Mar 2007 13:31:17 -0500 Received: from localhost ([127.0.0.1]) by iconoclast.caedmon.net with esmtp (Exim 3.35 #1 (Debian)) id 1HTMd9-0004mm-00; Mon, 19 Mar 2007 14:30:51 -0400 Message-ID: <45FED6D9.8030307@caedmon.net> Date: Mon, 19 Mar 2007 14:30:49 -0400 User-Agent: Thunderbird 1.5.0.9 (X11/20070103) MIME-Version: 1.0 To: Stanislav Malyshev CC: Wez Furlong , internals@lists.php.net References: <86478A67-DCA2-4000-9EF0-DA4338E8389B@omniti.com> <45FDF031.4010508@zend.com> <45FE2312.1050506@zend.com> In-Reply-To: <45FE2312.1050506@zend.com> X-Enigmail-Version: 0.94.2.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: sean@caedmon.net (Sean Coates) > Well, making it work makes this thing closure. Otherwise it's just a > nice way to save a couple of keystrokes :) Not to diminish your work, > but there's a danger people would think it is closure because it looks > like one (i.e., in other languages closures look exactly this way, e.g. > Javascript). I think this is the key to this whole discussion. I doubt PHP will ever be able to fully support JavaScript- and Lisp-style closures. To take Stas' example to another level: function foo() { $bar = function () { echo "bar"; } return $bar; } $bar = foo(); $bar(); // does this work? According to our current current syntax: function foo() { $bar = create_function('', 'echo "bar";'); return $bar; } $bar = foo(); $bar(); // this does work I don't know Lisp very well at all, but in JavaScript, functions are general containers, and this sort of thing works fine, albeit VERY differently. PHP's scoping rules are already completely different from JavaScript's (there's no way to access the parent scope unless it happens to be the global scope). I strongly prefer Wez's syntax for anonymous function declaration. It would help on many levels, from readability to syntax-highlighting, to optimization (maybe...). On optimization, the question becomes "how does Wez's proposal tokenize?" --------Old: T_OPEN_TAG :