Hello
everything is in the title but let me explain this a little better with an example:
(You can run it in
http://try.haxe.org/)class Test {
static function main() {
trace("Haxe is great!");
var extendedClass:ExtendedClass = new ExtendedClass();
extendedClass.init().start(); // that obviously gives me an error as BaseClass has no field start }
}
class BaseClass {
public function new()
{
}
public function init():BaseClass
{
trace("BaseClass init !");
return this;
}
}
class ExtendedClass extends BaseClass {
public function start():ExtendedClass
{
trace("ExtendedClass start !");
return this;
}
}
So the comment in red explains what the problem is. BaseClass does not have a start field to call. And it's perfectly normal.
I guess it would run perfectly if the compiler wasn't there to check that there might be an error.
What would be cool is, instead of specifying BaseClass as the returning object type of a function, specify some kind of a special type (like "This") so the compiler knows that it is the actual extended object (the final one) and not just the BaseClass...
Hope I made myself clear enough.
Maybe I could achieve that with macros ?
I would gladly accept any help for that :)
Thanks.
Thomas.