Every enum declared in Haxe outputs to an Enum class at runtime. Why cannot haxe simply output enums as integers, as in:
mode == VideoModes.RECORDING // RECORDING = 2
Possible Output in SWF/Binary:
mode == 2
Current Output in SWF/Binary:
mode == VideoModes.RECORDING
I’m not 100% sure of the way it currently outputs because its from memory, I’ve not double-checked with my decompiler, but you get the point. Why do enums output as classes when they can simply output as integer checks?
No idea what this is default, but you can have such enums, they are called abstact enum: http://haxe.org/manual/types-abstract-enum.html.
Thank you for your extensive help, ibilon! The enum inlining feature is so beautiful! I wonder why all enums are not exported like that by default!
The downside of the abstract enum is that the type is not available at runtime (it’s just an integer), which generally should not matter, but I knew at least one company that had set up interfaces that expected Flash classes of a certain type (for what we translate to enums) and this information was lost in their specific case. I had been using abstract enums almost across the board (since their introduction in Haxe 3.1) but ended up reverting it.
However, I still use it within Lime, and it’s awesome – we can do a Haxe abstract enum, and have it translate perfectly to and from C++ enums, the method we use to communicate between native C++ code and Haxe code does not handle enums, but handles integers just fine. It works perfectly, and I like the strength of still having all the benefits of real enums (and not just numbers) but boiling it down to the basics at compile time