Type issues in Haxe-JS

23 views
Skip to first unread message

Franco Gotusso

unread,
Nov 28, 2012, 7:14:44 AM11/28/12
to haxe...@googlegroups.com
Hi, I'm mixing Haxe 2.10 with native JS code, and I found a unexpected behavior with a snippet like this:

    var externalVar : Dynamic = "";
    var internalVar = 0;
    trace(externalVar == internalVar);

In my code externalVar is read from a native JS library, and as the compiled output use "==" operator, javascript is making a cast and the result is true.

The same snippet in Neko prints false. I think, as Haxe is strongly typed, the JS code should print false as well.
Is this a bug or it's supposed Haxe-JS works in this way?

Nicolas Cannasse

unread,
Nov 28, 2012, 8:15:20 AM11/28/12
to haxe...@googlegroups.com
Le 28/11/2012 13:14, Franco Gotusso a �crit :
Operations on Dynamic are platform-specific. We don't try to generate
additional code to ensure the same cross platform behavior and instead
prefer to get the best (native) performances.

Best,
Nicolas


Cauê Waneck

unread,
Nov 28, 2012, 8:24:11 AM11/28/12
to haxe...@googlegroups.com
Couldn't we use === for all '==' comparisons in JS? It should be faster also, shouldn't it?

2012/11/28 Nicolas Cannasse <ncan...@gmail.com>

Nicolas Cannasse

unread,
Nov 28, 2012, 8:30:24 AM11/28/12
to haxe...@googlegroups.com
Le 28/11/2012 14:24, Cau� Waneck a �crit :
> Couldn't we use === for all '==' comparisons in JS? It should be faster
> also, shouldn't it?

This will cause other issues, in particular undefined !== null

Best,
Nicolas

Reply all
Reply to author
Forward
0 new messages