diff options
| author | Mistivia <i@mistivia.com> | 2025-06-24 16:47:52 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-24 16:55:20 +0800 |
| commit | ec5910bea4db98b40db374a2484380fe1892c563 (patch) | |
| tree | 120cca8628be7868e0eafdac33b89f885f79a0cb /src/interp.c | |
| parent | 65cd835954825568a432c2e62d8019269dcafd74 (diff) | |
tailcalll on let block
Diffstat (limited to 'src/interp.c')
| -rw-r--r-- | src/interp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/interp.c b/src/interp.c index 80ddfed..65eeaff 100644 --- a/src/interp.c +++ b/src/interp.c @@ -478,6 +478,13 @@ SExpRef lisp_macroexpand1(Interp *interp, SExpRef macro, SExpRef args) { PUSH_REG(fn); SExpRef ret = lisp_apply(interp, fn, args, false); POP_REG(); + while (VALTYPE(ret) == kTailcallSExp) { + fn = REF(ret)->tailcall.fn; + args = REF(ret)->tailcall.args; + PUSH_REG(ret); + ret = lisp_apply(interp, fn, args, false); + POP_REG(); + } return ret; error: return new_error(interp, "macroexpand: syntax error.\n"); @@ -734,6 +741,7 @@ end: return ret; } + SExpRef lisp_eval(Interp *interp, SExpRef sexp, bool istail) { if (interp->recursion_depth > 2048) { return new_error(interp, "eval: stack overflow.\n"); |
