COMMUNITY

Rtti/Meta constants

Hej all,

Is still @:rtti often used or will this feature be removed in a future ?
I ask that because I’m using it and I wonder why it’s still in a Xml format and not regular haxe variables. I think it’s mostly for documenation generation but maybe I miss something.
If it would be in another format, like Haxe regular variables, then we could store not only Constants, Arrays and Objects declarations in Metas but we could have all expressions stored.
Can anyone tell me more about this feature and if there are maybe plans to change something about it or remove it ?
Thanks,

AFAIK there is no plan to remove this feature currently. And yet I doubt this feature is widely used.
If I would need type info at runtime I’d use some macros for that instead of rtti.

1 Like

Thanks Aleksandr !

Yes I used some macro to get my own field descriptions, then I thought about rtti and I said that it’s good to use Haxe built in features, so I transform all my custom things into rtti and then I see that there are many limitations, that pitty, maybe it could just be a bit improved in the future because it’s a good “built in” feature IMHO.

One issue with the built in RTTI is that it’s very general-purpose-y (and thus rather heavy), e.g. it’s also what’s used by dox. The advantage is of course, that it’s built right in and doesn’t require maintenance on your part. The advantage of macros is that you can tailor them to your use case and also make some static checks while you’re at it (e.g. forbid Dynamic or some such thing).

Only you can decide which approach better suits your needs, but RTTI is not so easy to improve without breaking changes, so realistically, you shouldn’t expect too much improvement on that front.

Thanks Juraj for your answer,

To be honest, I don’t expect anything from anybody. I achieve all what I need.
Sometimes I just ask why things are like that and emit suggestions but of course I don’t always see the whole things.
Here my feeling is that Rtti is no longer very useful for runtime type informations but just for output like documentation, that’s why I ask if it will be removed or renamed ?
Another thing is about Metas, that are IMHO a bit different from whole Rtti because can be still used in code and it could maybe be hold in a different way in order to have expressions stored and not only constants.
What I want also to say is that some of “old haXe features” like that that will stay like that make contrast with some new Haxe features that are really advanced.