Re: Closures as methods (and Closure::bind)

From: Date: Wed, 11 Aug 2010 13:57:47 +0000
Subject: Re: Closures as methods (and Closure::bind)
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-49332@lists.php.net to get a copy of this message
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

« previous php.internals (#49332) next »