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

Is it possible to evaluate function entry and exit? #33

Open
jasonvasquez opened this issue Jun 20, 2018 · 1 comment
Open

Is it possible to evaluate function entry and exit? #33

jasonvasquez opened this issue Jun 20, 2018 · 1 comment

Comments

@jasonvasquez
Copy link

In this example, I have an ExpressionContext owner that has a concept of a DateTime as part of its instance data. I'm trying to write an expression such as:

metric(123) - yesterday(metric(123))

Where metric() is a function that performs a query, using the current date as an input. When the runtime hits the yesterday outer function, I'd like to modify the owner's instance data before the inner expression is evaluated, and then restore it when the inner expression is complete. (Basic push/pop behavior)

Does Flee support this kind of behavior?

@hunkydoryrepair
Copy link
Contributor

so, the compiled expression would generate something like this:
load 123
call metric
load 123
call metric
call yesterday
subtract

"Yesterday" is the next to last thing evaluated, after metric has completed. Flee isn't really designed to change state, so modifying a variable in the middle of evaluating the expression may have unpredictable results.

But, if you wanted to try, you'd have to put a method inside the call to metric:

yesterday(pop(metric(push(123))))

you'd implement your push/pop methods to change the owner value and return whatever was passed to it.

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