Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49429 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55501 invoked from network); 12 Aug 2010 17:31:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2010 17:31:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:52027] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/20-09694-3FF246C4 for ; Thu, 12 Aug 2010 13:31:32 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 6EACB7000438 for ; Thu, 12 Aug 2010 18:31:28 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id MKZUDnzLBFRs for ; Thu, 12 Aug 2010 18:31:28 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 2D75B700042C for ; Thu, 12 Aug 2010 18:31:28 +0100 (WEST) Received: from cataphract-old.dulce.lo.geleia.net (a83-132-178-216.cpe.netcabo.pt [83.132.178.216]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id F31E520010B8 for ; Thu, 12 Aug 2010 18:31:27 +0100 (WEST) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: internals@lists.php.net References: <1281535067.1132.15.camel@guybrush> Date: Thu, 12 Aug 2010 18:31:16 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Organization: =?iso-8859-15?Q?N=FAcleo_de_Eng=2E_Biom=E9dica_?= =?iso-8859-15?Q?do_IST?= Message-ID: In-Reply-To: <1281535067.1132.15.camel@guybrush> User-Agent: Opera Mail/10.60 (Win32) Subject: Re: [PHP-DEV] Closures as methods (and Closure::bind) From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Wed, 11 Aug 2010 14:57:47 +0100, Johannes Schl=FCter = wrote: > On Wed, 2010-08-11 at 14:38 +0100, Gustavo Lopes wrote: >> I've updated the wiki page for "Closures with objects extension" with= >> things that are in "Proposal A with modification"s but are not = >> implemented: >> >> http://wiki.php.net/rfc/closures/object-extension#status_as_of_august= _10_2010 >> >> I propose an implementation of "closures stored in properties used as= >> methods", as in: >> >> $this->prop =3D function () { ...} >> $this->prop(); >> > [...] > I don#t have an opinion on this feature, yet, I like the current > class-based object model as reading code is relatively simple, with th= is > addition (and the fact that you can create properties on the fly) we > create a powerful tool for really hard to read code. > It's important to understand this is not mere syntactic sugar over $a =3D $this->prop; $a(); or call_user_func($this->prop). It actually allows executing closures in= a = way that fails if the staticness or bound instance of the closure is not= = what was expected. See the beautiful tree graphs on the wiki page. -- = Gustavo Lopes