Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47044 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49654 invoked from network); 24 Feb 2010 07:38:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2010 07:38:53 -0000 Authentication-Results: pb1.pair.com header.from=mathieu.suen@easyflirt.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mathieu.suen@easyflirt.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain easyflirt.com designates 91.199.255.56 as permitted sender) X-PHP-List-Original-Sender: mathieu.suen@easyflirt.com X-Host-Fingerprint: 91.199.255.56 python-06.easyrencontre.com Linux 2.6 Received: from [91.199.255.56] ([91.199.255.56:36900] helo=mail.easyflirt.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/89-26388-B87D48B4 for ; Wed, 24 Feb 2010 02:38:53 -0500 Received: from [192.168.0.51] (office.easyrencontre.com [78.155.152.6]) by mail.easyflirt.com (Postfix) with ESMTPSA id DE8326374D3; Wed, 24 Feb 2010 08:38:48 +0100 (CET) Message-ID: <4B84D787.202@easyflirt.com> Date: Wed, 24 Feb 2010 08:38:47 +0100 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Stanislav Malyshev CC: internals@lists.php.net References: <4B54FC87.8070106@zend.com> <4F.56.22457.408955B4@pb1.pair.com> <4B55D850.8000604@zend.com> <4B808294.1070801@keryx.se> <4B844DBA.4050804@zend.com> In-Reply-To: <4B844DBA.4050804@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] On closures and lamdba From: mathieu.suen@easyflirt.com ("mathieu.suen") Stanislav Malyshev wrote: > Hi! > >> My question is not so much about implementation it is about language. I >> have noticed quite a few times now that PHP developers use the word >> "closure" when I would prefer "lambda". > > Everybody on the internet knows that Wikipedia is the ultimate source > of knowledge, and it says: > > In computer science, a closure is a first-class function with free > variables that are bound in the lexical environment. Such a function > is said to be "closed over" its free variables. > > I think this describes what PHP is doing. > >> However, in the PHP manual as well as on this list, you seem to be >> saying "closure" === "anonymous function" (which is what I'd rather see >> called lambda). > > This is not entirely correct, you are right. There's a difference > between anonymous function and closure, though in practice in PHP > anonymous functions are closures (though some of them are rather > trivial ones with no variables to "close over") and that's now the > only way to do closure in PHP (i.e. you can't have non-anonymous > closure function). I would rather say that PHP have both. Closure is just a subset of lanbda. You say that a lambda is a closure whenever the lambda capture variable from its outer scope. You even have a special syntactic form to declare a lambda to be a closure, the keyword "use". -- Mathieu --