Closed kvnxiao closed 1 year ago
I'm currently using this as a bandaid solution for my use case. Let me know if you think there's a better way this can be structured and represented in the code.
Great! You'll need to decrement it as well though, since the stack won't overflow if you go in and out of recursions a lot. To make that work you'd probably need to increment right before function calls and decrement right after. Easiest would probably be to put that in eval_expr in the match arm for FnCall.
Would it make sense to only increment / decrement the depth counter within this part of the FnCall code?
match stmt_definition {
Some(Stmt::FnDecl(_, arguments, fn_body)) => {
// ... <somewhere here in this body?>
Or did you mean something like:
// fn eval_expr(...)
match expr {
// ...
Expr::FnCall(identifier, expressions) => {
context.recursion_depth += 1;
let res = eval_fn_call_expr(context, identifier, expressions, unit);
context.recursion_depth -= 1;
res
}
I updated the PR code, let me know if you think there's other things worth moving around
Looks good, thanks!
E.g.
Before:
After: