[haXe] Abstract Classes?
Daniel Cassidy
lezekdan at gmail.com
Wed Dec 13 17:49:10 CET 2006
Hi Nicolas,
On 11/7/06, Nicolas Cannasse <ncannasse at motion-twin.com> wrote:
> Yes, that's problematic. I update haXe, in 1.09, you will be able to
> define private functions in typedef :
>
> typedef UserApi = {
> private function getName():String;
> private function getText():String;
> }
>
> This will not require that the function is actually private since an
> hidden method can be redefined as visible, but not the other way.
This turns out not to be all that useful:
A.hx:
--------------
class A {
private var aApi:AApi;
private function new (aApi:AApi) {
this.aApi = aApi;
}
public function foo () {
aApi.bar(); // cannot access to private field bar
}
}
typedef AApi = {
private function bar ():Void;
}
---------
B.hx:
---------
class B extends A {
public function new () {
super(this);
}
private function bar ():Void {
trace("bar");
}
}
--------
Main.hx:
--------
class Main {
public static main ():Void {
var b:B = new B();
b.foo();
}
}
--------
A.hx fails to compile, since access to the private function in the
typedef doesn't seem to be allowed, even from the same file. This
looks like a bug?
Thanks,
Dan
More information about the Haxe
mailing list