-
-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__init__ on java and c# not called at start #8933
Comments
IMO we should unspecify this. Trying to hack around the natural initialization behavior of these targets would come with various problems. |
I think the whole idea of |
That's a noble goal, but it's not compatible with how initialization works on these targets. In the general case we would have to generate all This is just not reasonable. |
The current behaviour feels wrong for me. class A {
static public final __force_init__ = [];
public function new() {
trace("A");
}
static function __init__() {
trace("init A");
}
}
class B {
static public final __force_init__ = [];
public function new() {
trace("B");
}
static function __init__() {
trace("init B");
}
}
class Main {
static final __force_init_A__ = A.__force_init__;
static final __force_init_B__ = B.__force_init__;
static function main() {
trace('main');
new A();
trace('here');
new B();
}
} yeah its ugly, but now I get a consistent output on these targets. The only difference now is that |
But that is just trading one inconsistency for another. |
yes, but |
I would be willing to change it so the compiler collects all classes that have an However, we still cannot comply with the original specification which says that all |
If that is the specification than it is broken on some targets anyway :) class Main {
static var test = [1,2,3];
static function main() {
trace("Haxe is great!");
}
static function __init__() {
trace(test);
}
} on Js I get: on interp I get: |
I thought Anyway I'd prefer |
at least we can agree, that it is not following any specification up to now.... |
I think it does that on all targets already. |
on eval it runs after static initialization as shown above. And on cs and java it runs unpredictable. |
on Java and C# the initialization order of classes is weird. If they have a
__init__
function, this is not called on startup, but on the first time the class is used:gives this out put:
on other targets you get this:
The text was updated successfully, but these errors were encountered: