macros article: accessing structure properties
Similar to "Combine two or more structures" adds methods to list properties and read/write. I though interesting to have another example on this since that was the only one mixing macros and static extensions and it's useful.
The props function can be improved (no need to do three passes). But more importantly, the get and set functions are useless, they are simply identical to accessing the field of a structure (as the compiled output shows). You cannot provide a dynamic field name to the functions, it has to be a constant, since the argument is a String. There is no Reflection fallback, and reflection is necessary to access fields dynamically.
So a.get("foo") is just a.foo …
@Aurel300 aja, thanks.Maybe I was too quickly to create this PR. My objective is to list all properties, iterate and then get/set dynamically, but maybe is not possible. COuld you let me check/test and if I conclude is wrong just close this PR since it doesn't add any value to the existing article ? THanks
It sounds like you're looking for haxe.DynamicAccess (convenience wrapper for reflection).
Closing due to lack of follow-up.