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

Runtime compilation? #79

Open
licoricee opened this issue Aug 20, 2022 · 1 comment
Open

Runtime compilation? #79

licoricee opened this issue Aug 20, 2022 · 1 comment

Comments

@licoricee
Copy link

Is it possible to compile these templates at runtime? with a function or something?

@enthus1ast
Copy link
Owner

Currently there is no real good way, the only semi good option is hot code reloading, so that your application checks if the templates has changed, then calls the nim compiler to recompile the templates to a dll, unloads and reloads this dll.
See:
https://github.com/enthus1ast/nimja/tree/master/examples/hcr
and
https://github.com/enthus1ast/nimja#automatic-recompilation--hot-code-reloading-hcr

The benefit of this is, that they are as fast as normal templates, the downside is that you must restructure your application a little.

Real Runtime evaluation however is still a planned feature, and there is code for this already in the "dynamicAgain" branch (and some more i have not published yet).
The way i want to go is to include the compiler as a library, let nimja generate PNodes (instead of NimNodes) and execute these directly in the nimvm. The challenge here is, that the compiler api is quite undocumented and complicated to use (for me at least); and the other challenge is to convert parameters from native nim types, to PNodes that can run directly on the vm.

So in short, i would love to have this as well, but its not yet done.

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