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

Compile only required prelude functions #99

Open
itchyny opened this issue Mar 5, 2022 · 3 comments
Open

Compile only required prelude functions #99

itchyny opened this issue Mar 5, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@itchyny
Copy link
Collaborator

itchyny commented Mar 5, 2022

Currently xq seems to compile all the prelude functions even if they are not needed. This is overhead as most prelude functions are not required in most use cases. Also, it would be useful when adding functions to prelude, if the order does not matter.

@MiSawa
Copy link
Owner

MiSawa commented Mar 5, 2022

Yeah that'd be great. It might be not too hard to implement it by just making funcdefs register name, arg types and lazy-compiling function.
Though allowing function calls to the functions defined below of it might be a bit more difficult, because it would require the caller of those lazily compiling functions to have a reference to a proper scope, and I'm not sure what scope would be proper 🤔. If we'd do this disordered function resolving thing only on the module top level functions, that proper scope would be the scope at the end of the module compiling I guess. If we were to apply this to other function definitions.... I don't know, maybe we'd have to change parser to treat a chain of function definitions differently.

@MiSawa MiSawa added the enhancement New feature or request label Mar 12, 2022
@MiSawa
Copy link
Owner

MiSawa commented Apr 6, 2022

Actually I have a feeling that prelude functions should be compiled at the compile time in build.rs and embedded to the module loader.

@itchyny
Copy link
Collaborator Author

itchyny commented Apr 7, 2022

That would grow the executable size so it's trade-off between time and space.

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

No branches or pull requests

2 participants