Have you ever had an issue where the name of your class doesn’t match up with the output in Haxe? I know I have, and there is a simple fix for this issue, which will help you when creating libraries, APIs, and bindings to other libraries in separate languages.
In Haxe, there are tags known as metadata tags. These allow you to do several things to the code based on which tag you use. You can find more information here. With that said, the way to change the name of a class or a property in Haxe is with the @native meta tag. Meta tags allow you to modify the behavior in the Haxe code. Each one has a specific use, but for now, we’re focusing on the current tag. Let’s look at an example below from my own code.
As you can see above, all you need to do is add the tag above the property you want to change the name of; this could be a class, a property, or a function name. By using the native tag, we can make variations of the same function with type safety, avoid naming conflicts with other classes across the codebase (this was my use case). This is just the beginning.
There are a variety of tags you can use to help get something done in Haxe quickly and create something great! The ones I used today are compiler metadata flags. With that in mind, hope this helps you on your Haxe journey, and have a good one.
For more information on tags, you can find it here.