You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As we can see, it doesn't contain the f method because it uses type parameter which is not available in the interface, so the call to A<Dynamic>.f will generate a heavy dynamic call:
I've thought about that, and the only reason I haven't implemented this is due to code size. I've always been trying to find a good balance between performance and code size. Let me know your thoughts about this
Are we talking about IL code size or just generated C#? Don't C# compilers have some kind of DCE to remove unused code?
If it's about generated C#, I can understand the point about it being concise not to scare newcomers, but still IMO performance is always more important. Actually, I think it would be great to have some document that describes what code is generated and the reasoning behind that, for those who love nitpicking generated code.
@nadako C# compiler cannot remove unused code just because it looks like it's not used in current assembly. It could be used via reflection, or maybe used from other assemblies.
If code size is a concern, we may need to have a haxedef that disables interface generation globally, and metadata that does the same thing with per-class basis.
Okay, let's implement stuff with performance in mind first, then look how we can reduce code size. I see e.g. Unity3D now have an unused bytecode stripper, Java's ProGuard hopefully will do a good job removing unused bytecode as well. And finally, we could try stuffing all such transforms pre-DCE, so it can be removed naturally by Haxe compiler.
Just an idea. Suppose we have:
Currently this generates an interface for use as
A<Dynamic>
:As we can see, it doesn't contain the
f
method because it uses type parameter which is not available in the interface, so the call toA<Dynamic>.f
will generate a heavy dynamic call:How about we add a dynamic version of parametrized method to the interface, i.e.:
and implement that in the actual class that will do proper casting:
and at the call site,
A<Dynamic>.f
will be generated a lot prettier:Are there any potential problems with that approach? cc @waneck
I wonder how hxcpp handles that btw.
The text was updated successfully, but these errors were encountered: