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

Specify evaluation order regarding functions #292

Open
SirNickolas opened this issue Sep 17, 2019 · 2 comments
Open

Specify evaluation order regarding functions #292

SirNickolas opened this issue Sep 17, 2019 · 2 comments
Labels

Comments

@SirNickolas
Copy link

SirNickolas commented Sep 17, 2019

-term = {J()}
msg = {I(G(F(), named: ""), H())}, {-term}, {K()}

Functions are written in the host language and can both observe and mutate the global state (as well as the bundle they are called from), so order of evaluation should be defined for better portability.

Implementations should be allowed to skip evaluating functions when they hit their internal limits (neccessary for #277).

@Pike Pike added the resolver label Sep 17, 2019
@spookylukey
Copy link
Contributor

spookylukey commented Sep 17, 2019

If we over-specify here, we could end up eliminating some big possible optimizations. For example, an implementation might want to pre-evaluate constant expressions (such as -term above), so in terms of evaluation will do it at compile time, not runtime. This depends, of course, on functions being pure - see #294.

One use case for this would be a OSNAME() function which takes no arguments and therefore an optimizing implementation could run it at compile/deploy time (without special knowledge of the function), and produce smaller bundles for each OS.

@SirNickolas
Copy link
Author

Oh, yes, everything I said before only applies to impure functions. An implementation is free to reorder or drop calls to pure ones as long as the result stays the same, and nobody is going to notice these changes, because functions are pure. This opens broad possibilities for constant folding and common subexpression elimination. But that requires knowledge which functions are pure and which are not.

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

No branches or pull requests

3 participants