delegating to typed objects

Kris Zyp kriszyp at xucia.com
Mon Jul 9 14:42:20 PDT 2007


It seems to me that transfering bound methods to the function instances
makes the situation equally confusing:
 Now if write:
 class C { var x : String; function m() : String { return this.x }}
c = new C;
function F() {}
F.prototype=c;
f = new F; // f.__proto__ = c
f.x =4;
f.m() -> ???
A Transferred bound method would mean that when we call f.m(), that the
"this" in the method execution is actually c and not f. Does that really
make sense?
Kris



> But it could be allowed, just as the following is allowed when a method m
> is added to the class C defined above,
>
> > var o = {}
> > o.g = F.prototype.m
> > o.g ()
>
> 'this' is bound to 'c' in 'g'.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20070709/bc3f8b48/attachment-0002.html 


More information about the Es4-discuss mailing list