I was just reading the Self type proposal for the first time
(http://wiki.ecmascript.org/doku.php?id=proposals:self_type).
How should a compiler handle this keyword? Should it be able to
substitute a concrete type at compile-time, or must the actual type be
evaluated at runtime (possibly with varying results)?
To give an example of what I am getting at, would the following be an
error (in strict mode)?
type A = {x:Self};
class B extends A {}
var b:B = new B().x; // error: can't implicitly coerce from A to B ??
Or...
function A (){}
A.prototype.f = function():Self{
return this;
}
function B() {}
B.prototype.f = A.prototype.f;
Is this going to work as intended?
Or can't Self be used outside of the sorts of usage found in the
proposal examples?
Finally, on naming, I don't think it should be upper-case. It's a
keyword, not an actual type. But even "self" , like the lexical
"this", more suggests an instance not a type.
Perhaps "this type" might be clearer, and more akin to the "this
generator" and "this function" that have been proposed elsewhere.
Peter
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss