Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49332 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13573 invoked from network); 11 Aug 2010 13:58:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2010 13:58:04 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 unknown Solaris 10 (beta) Received: from [217.114.211.66] ([217.114.211.66:54471] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/D1-01618-06CA26C4 for ; Wed, 11 Aug 2010 09:57:53 -0400 Received: from [192.168.1.31] (ppp-93-104-115-144.dynamic.mnet-online.de [93.104.115.144]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id BDE0D24E44; Wed, 11 Aug 2010 15:57:48 +0200 (CEST) To: Gustavo Lopes Cc: "internals@lists.php.net" In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Wed, 11 Aug 2010 15:57:47 +0200 Message-ID: <1281535067.1132.15.camel@guybrush> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Closures as methods (and Closure::bind) From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) 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 = function () { ...} > $this->prop(); > > A few issues that may merit discussion (copied from the wiki page): A few more things coming to mind without much thought: * What if both a method and a property with the name exist? * What about allowing properties with function names as strings or array($obj_or_class, 'method'), won't that be needed for being consistent with local variables? * In the array($object, 'method') case: What's the scope for $this? 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 this addition (and the fact that you can create properties on the fly) we create a powerful tool for really hard to read code. johannes