I am sure this must be properly addressed somewhere, but I just cannot find where.
I am starting to experiment with Haxe and one of the things about which I have not been able to find clarity is whether it is possible to create “value” types. By this I mean a type that is created on the stack and that is generally passed around by copy like an integer or a float, as opposed to being allocated on the heap and passed around by reference. Importantly, a collection of a value type (e.g. an array) would store the values themselves, not references to the objects. A typical example would be things like Vector2 or Vector3 in video games. I thought that anonymous structures might be something like that, but according to the manual their performance is actually worse than for classes, so I suppose they are implemented as a sort of dictionary on static targets.
My impression is that this is not possible in Haxe, but I have not found explicit documentation about it. I know there are inline constructors that do something like that, but I’m not sure it is quite that (e.g. what happens if I have an array of a type with an inline constructor?).
I suspect this is partially, or totally, due to the multi-target nature of the language, so things might in principle work differently on different targets. But it seems a relatively important aspect. For example, there is this idea of Structure of Arrays (SoA) that some games or engines implement to gain some performance from better cache locality (it is frequently associated with ECS designs, although one doesn’t necessarily imply the other). But this only makes sense if you can store value types in your arrays, not references. So, is it possible at all to have a SoA design in Haxe (for anything else than boolean, integer or float values)?