> > Or can't Self be used outside of the sorts of usage found in the
> > proposal examples?
>
> That's it.
>
In that case, I think it needs to be clearer about how the syntax can
be used. Is it only for use as the "this" parameter for function
types? Seems to me like it should be usable anywhere that the compiler
can reasonably detect the type at compile-time.
e.g.
// this usage is handy for boiler-plate code that you can just copy
// and paste without modification, or from an IDE code snippet template
class A {
var a:Self;
// or...
// var a:this type;
}
type B = {b:Self};
Other places where special treatment of the keyword would be useful is
in interfaces, where the a function argument or return value should be
the same as the type:
interface IClonable {
public function clone():Self;
}
class A implements IClonable {
public function clone():A { return new A() };
}
That is, users of the interface see the type as being the same as the
interface, but implementors must use their own type here. The example
is identical to clone's return type being IClonable, except that
implementors are required to declare a stronger type.
Peter
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss