Juraj
When I say that it’s too much work for nothing, this is because at the begining I was looking for just a Haxe keyword or built in feature that allows to BYPASS HAXE TYPE CHECK SYSTEM AT COMPILE TIME (without any run-time overhead).
You’re as obstinated and chatty as I am !
I’ll explain how my brain worked and propulsed me here to “talk” with my coding friends :
- At the begining, I found by myself that unsafe cast does almost what I want. I compiles well and it’s ok.
- Then I came here to ask the difference between unsafe cast and the type check (e:T), because for me these 2 options are very close and I was sure that unsafe cast doesn’t bring any run-time overhead.
- BUT Kevin told that in fact sometimes even unsafe cast can add some run-time overhead on some plateforms…
- So, my brain focused again on the type check (e:T) that doesn’t bring any run-time overhead BUT Jens said that type check is not really doing what I thought
- So again, I was confused with (e:T) and in fact I still don’t really understand the utility of this feature (here you can help me if you want to answer, with maybe some simple examples
)
- Then Kevin bring another solution (and I thank him again for this try) using macros to ensure that all is strictly typed and does what I want. This is very cool but at the end I just realized that I don’t really want to use macros to ensure that on compile-time all types are ok because it’s my own code, I don’t share it without any other coders, so I KNOW WHAT I DO and I just wanted again to find a way to BYPASS HAXE TYPE CHECK SYSTEM AT COMPILE TIME
That’s all !
Then, reading you’re last paragraph, static function foo<T:Class<Dynamic> & { function bar():Map<String, String>; }>(cl:T)
is antoher interesting and elegant solution and I haven’t thought about that. I think that if you had written that at the begining, I would be satisfied and even maybe get an orgasm (but once again, I think my bad english create sometimes confusion about what I’m really looking for…)
You’re last solution also show’s me that in fact, I have a misunderstanding of how Haxe manages Types globally, because I must admit that I’m not really comfortable with generics
and all related with Type casting as seen here with the Type Checking (e:T). All that occurs on compile-time.
If there is somewhere a good tuto to explain step by step the utility of generics agains Dynamic for example and at the end as I asked, the real utility of (e:T) I would be happy.
And what about my research of not having run-time overhead is not because I care to have the fastest and smallest generated code, it’s once again related just to this topic to just find a way BYPASS HAXE TYPE CHECK SYSTEM AT COMPILE TIME , once again related to these 2 options between unsafe cast and type check.
Thanks all my friends coders, have a nice day !