-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Allow lazy evaluation of some expressions #663
Comments
I don't know if constructing a whole RPN tree would be necessary for these, at least not for short-circuiting logic operators. Instead, consider an User-defined functions are more complicated but might also be doable without RPN trees. Their body would be captured like a macro body when they're defined. Then when they're called, the parser would expand the function body similar to a macro body, but instead of substituting the parameters |
The proposed solution for user-defined functions would imply re-parsing them, which is slow, and can be avoided since the expression tree won't change. This is why I'm pushing so hard to decouple expression evaluation from parsing. Evaluation can still be eager for purely numeric expressions ( I believe this is necessary for a proper user-defined function implementation, notably to avoid technical debt, and since I think it also encompasses the other usages, I think we shouldn't use "partial" impls. This is why I've been reluctant to merge #665. |
Here are my thoughts on implementing this:
This way, Am I missing anything there? |
To avoid reserving half of the IDs for errors, the defined error values could count down from $FF, and check for a minimum threshold value instead of the high bit. |
This is an internal requirement for features including:
def f(x) = x * n
wheref(5)
will multiply by whatevern
currently is)WHILE
loops&&
and||
(so2+2==4 || foo/bar==1
will evaluate to1
even iffoo
is undefined orbar
is 0)cond ? then : else
)The text was updated successfully, but these errors were encountered: