Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace static field initialization in typed types #4817

Closed
back2dos opened this issue Jan 28, 2016 · 4 comments
Closed

Replace static field initialization in typed types #4817

back2dos opened this issue Jan 28, 2016 · 4 comments

Comments

@back2dos
Copy link
Member

Would it be possible to allow replacing static field initialization in already typed types under certain circumstances? I think it should suffice for the field to be physical and not be inline.

The main motivation is to be able to put data somewhere that has been accumulated by macros without having to resort to resources or metadata: https://groups.google.com/d/topic/haxelang/zqpQI2t0DwI/discussion

For complex data the only way to do it now is to use resources, which requires haxe.Unserializer in the output and that adds quite a chunk, i.e. all the compat stuff, all the reflection metadata, for nothing. On JS it does make quite a difference.

@Simn
Copy link
Member

Simn commented Jan 28, 2016

I don't like the idea of changing type structures like that, it adds a whole new layer to what we have to keep in mind for internal development and I have no idea how the compilation server would react to it either.

I think you can already achieve something quite similar by defining a new type in onGenerate and pull some extern/@:native tricks with it. That means the static field is on another type, but that shouldn't be a problem. If onGenerate doesn't do the trick then the solution to #4714 is going to address it.

@Simn Simn closed this as completed Jan 28, 2016
@back2dos
Copy link
Member Author

I don't like the idea of changing type structures like that

My very point was to allow it only in cases where it does not affect the structure. I fail to see why replacing a value would affect the structure, so long as having a value is valid at all (i.e. the field is physical) and changing it does not affect any other module (i.e. the field is not inline and the replacement occurs before DCE). Would you please indulge me and explain to me what side effects there are under these circumstances if you type a new expr against the known field type and (assuming no type errors) replace the old texpr by the new one? Thank you.

@Simn
Copy link
Member

Simn commented Jan 28, 2016

My very point was that I don't want to think and worry about replacing expressions in typed types because it adds complexity. The existence of the compilation server alone is enough for me to turn this down, but even without it there's a lot of critical ordering going on in our post processing. For instance, onGenerate runs after important filters like rename_local_vars and the analyzer transformations which could easily lead to problems on various targets.

@back2dos
Copy link
Member Author

Ok, thank you, this gave me a vague understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants