diff options
| author | Mistivia <i@mistivia.com> | 2025-06-28 15:49:31 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-28 15:51:04 +0800 |
| commit | 0633c6c2797bc9182b2c1888385eac6cb6caed10 (patch) | |
| tree | e920255dda5b6fea67f3eef91b27c4dae069c63e /src/primitives.c | |
| parent | 9efc0e78ad1609217752b5aa02fbb389d726e9c7 (diff) | |
add unwind-protect
Diffstat (limited to 'src/primitives.c')
| -rw-r--r-- | src/primitives.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/primitives.c b/src/primitives.c index a8bb62a..9f3e670 100644 --- a/src/primitives.c +++ b/src/primitives.c @@ -79,6 +79,17 @@ SExpRef primitive_eval(Interp *interp, SExpRef args, bool istail) { return lisp_eval(interp, args, istail); } +SExpRef primitive_unwind_protect(Interp *interp, SExpRef args, bool istail) { + if (LENGTH(args) < 2) { + return new_error(interp, "unwind-protect: syntax error.\n"); + } + SExpRef ret = EVAL(CAR(args)); + for (SExpRef i = CDR(args); !NILP(i); i = CDR(i)) { + EVAL(CAR(i)); + } + return ret; +} + SExpRef primitive_if(Interp *interp, SExpRef args, bool istail) { SExpRef cond, tb, fb; |
