Re: Closures and $this

From: Date: Wed, 16 Dec 2009 16:16:22 +0000
Subject: Re: Closures and $this
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-46448@lists.php.net to get a copy of this message
Richard Quadling wrote:
How much of a use case is binding $this to closures (personally, I think this is quite a common usage, but I've been using JavaScript so maybe I've got the wrong head on). But, if there are significant technical/internal issues with regard to binding $this to closures, what about (and I'm expecting the usual shoot down here as I obviously know squat) NOT binding closures at all (option 0). Instead get traits working.
*snip* If I recall the trait discussion properly, traits are a compile-time thing. Closure binding is a run-time thing. They are not comparable and one cannot really be used to implement the other. (Well, hypothetically bound closures could kinda-sorta replicate traits, but it would be a pretty lousy way of doing it as you get no compile-time enforcement or interface support.) --Larry Garfield

« previous php.internals (#46448) next »