Re: [RFC] prototyping
| From: | Xuefer | Date: | Wed, 14 Jan 2009 02:35:20 +0000 |
| Subject: | Re: [RFC] prototyping | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42615@lists.php.net to get a copy of this message | ||
just a note about it
in javascript, "this" ($this in php) is a special variable in closure,
"this" is always bound to the "object" of "object.method(...)" when it
is called, whenever i want a "this" of closure creation time context,
i use:
var _this = this;
return function() { _this.prop = 123; _this.method(); }
so..
> I see no reason to have two contexts in closure - one bound one way and
> another bound another way
it's already 2 contexts in php: $this and $_LOCALSCOPE (which is not
available in user code). and now $_CLOSURE context
the reason you think there's only 1 context maybe because $this is
implemented in $_LOCALSCOPE['this'] = &$this in php internally. :)
> I think context is a context - it's where the closure was created.
true, the $_CLOSURE context
prototype can be useful in php. and like closure that ppl got used to
javascript version of closure/prototype, there should be no big
problem understanding it.