[haXe] a haxe extern generator

Nicolas Cannasse ncannasse at motion-twin.com
Sat Feb 17 13:55:43 CET 2007


> hi all,

Hi Neil,

> I have written a haxe extern generator in perl, to convert a tree of
> actionscript files to haxe externs. I know there is another one floating
> around, so here's the next attempt. This project will let you use
> Actionscript2 (-version 8) projects in haXe.

Nice.

> - extending interfaces are not allowed in haxe, so I have left
> interfaces out of all externs. So far I do not get any compile problems,
> but maybe this can cause type related runtime errors?

What do you mean by "extending interfaces" ?

> - static members are not inherited in haxe (whereas counterintuitively
> they are in actionscript), so I have copied static declarations up the
> inheritance heirarchy.

This will not work.
In AS2, statics are inherited but they are still part of the super class
object prototype. For example the following :

class A {
    static var x;
}

class B extends A {
   function f() {
      return x; // gets compiled to A.x
   }
}

So you just must keep the "x" variable as a "A" static, and haXe users
will use A.x instead of simply using "x".

> - all function parameters become optional, and I've added 4 optional
> parameters to each function, in order to fake function overloading.

It would be better to have the default being not-optional, and allow
some kind of AS2 comments in function declarations, such as :

function f( x : String, /*?*/ a : Number /*...*/ ) {
}

that would get generated to :

function f( x : String, ?a : Number, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 :
Dynamic, ?p4 : Dynamic );

> There are some more issues, which I suspect arise from type problems.
> For example AsWing delegation does not work, which may be because you
> cannot pass functions as variables to Actionscript (I'm groping a bit
> for an explanation, I have to admit)...

An example maybe ?

Best,
Nicolas



More information about the Haxe mailing list