From 771499a17a7d6dcdc962e74201d7ee0ffa8d9f87 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 1 May 2018 20:17:57 -0700 Subject: interpreter: correct semantics of special var args. In this patch we eliminate the special operator sys:with-dyn-rebinds, and implement correct semantics for dynamically scoped variables that occur in argument lists. * eval.c (with_dyn_rebinds_s): Symbol variable removed. (bind_args): Handle special variables dynamically: for each symbol that appears, check whether it is a special and treat accordingly by allocating a new dynamic environment if necessary, and binding in that environment. This adds overhead, which is why I moved away from this approach in the past. But now that there is a compiler, overhead in the interpreter matters less. Correct semantics is more important. (expand_params): Greatly simplified for not having to wrap the sys:with-dyn-rebinds operator around the body. (funcall_interp): Since bind_args can now extend the dynamic environment, it is necessary to save and restore dyn_env around it. Another call to bind_args occurs in op_catch; that already saves and restores dyn_env. (op_with_dyn_rebinds): Static function removed. (do_expand): with-dyn-rebinds-s case removed. (eval_init): Removed interning of sys:with-dyn-rebinds symbol and registration of special op. * protsym.c: Regenerated. * compiler.tl (compiler compile): Remove case which handles sys:with-dyn-rebinds. --- protsym.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'protsym.c') diff --git a/protsym.c b/protsym.c index 5c0db635..87e2ff42 100644 --- a/protsym.c +++ b/protsym.c @@ -128,9 +128,9 @@ extern val ushort_s, uw_protect_s, val_s, var_k, var_s; extern val vars_k, vec_list_s, vec_s, vecref_s, vector_lit_s; extern val vm_closure_s, vm_desc_s, void_s, warning_s, wchar_s; extern val weak_keys_k, weak_vals_k, when_s, while_s, while_star_s; -extern val whole_k, wild_s, with_dyn_rebinds_s, word_char_k, wrap_k; -extern val wstr_d_s, wstr_s, year_s, zap_s, zarray_s; -extern val zeroplus_s, zone_s; +extern val whole_k, wild_s, word_char_k, wrap_k, wstr_d_s; +extern val wstr_s, year_s, zap_s, zarray_s, zeroplus_s; +extern val zone_s; #if CONFIG_DEBUG_SUPPORT extern val debug_quit_s; @@ -259,9 +259,9 @@ val *protected_sym[] = { &vars_k, &vec_list_s, &vec_s, &vecref_s, &vector_lit_s, &vm_closure_s, &vm_desc_s, &void_s, &warning_s, &wchar_s, &weak_keys_k, &weak_vals_k, &when_s, &while_s, &while_star_s, - &whole_k, &wild_s, &with_dyn_rebinds_s, &word_char_k, &wrap_k, - &wstr_d_s, &wstr_s, &year_s, &zap_s, &zarray_s, - &zeroplus_s, &zone_s, + &whole_k, &wild_s, &word_char_k, &wrap_k, &wstr_d_s, + &wstr_s, &year_s, &zap_s, &zarray_s, &zeroplus_s, + &zone_s, #if CONFIG_DEBUG_SUPPORT &debug_quit_s, -- cgit v1.2.3