O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The remap switch

The compiler has a remap switch that allows us to rename a package, for example, imagine the following code:

//Some previous code myPack.Lib.println("Hello remapping!"); //Some code following

This would obviously not work because the Lib class is not in the myPack package. However, if you compile with the switch --remap myPack:neko when compiling to Neko, this will work. The reason is simple: anywhere you have used the package name myPack; the compiler will replace it with Neko, therefore using the correct package.

This can be used to make some cross-platform code.

On the other hand, it has a big draw-back: when you remap a package, all of the modules it contains are remapped. This actually means that you won't be able to use something ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required