From e2437397f8f4430fd479cafe9495e5a19e970f86 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 20 May 2014 19:44:07 -0700 Subject: The call operator should be a function! * eval.c (call): New static function. (eval_args, op_call): Static functions removed. (eval_init): call_s registered as operator rather than function. * txr.1: Updated. --- ChangeLog | 10 ++++++++++ eval.c | 20 ++++++-------------- txr.1 | 16 ++++------------ 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e8b376c..c2fc1205 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2014-05-20 Kaz Kylheku + + The call operator should be a function! + + * eval.c (call): New static function. + (eval_args, op_call): Static functions removed. + (eval_init): call_s registered as operator rather than function. + + * txr.1: Updated. + 2014-05-10 Kaz Kylheku Version 89 diff --git a/eval.c b/eval.c index 38b60cd4..de1180ed 100644 --- a/eval.c +++ b/eval.c @@ -655,6 +655,11 @@ val apply_intrinsic(val fun, val args) return apply(fun, apply_frob_args(args), cons(apply_s, nil)); } +static val call(val fun, val args) +{ + return apply(fun, args, cons(apply_s, nil)); +} + static val list_star_intrinsic(val args) { return apply_frob_args(args); @@ -930,11 +935,6 @@ static val eval_lisp1(val form, val env, val ctx_form) return do_eval(form, env, ctx_form, &lookup_sym_lisp1); } -static val eval_args(val form, val env, val ctx_form) -{ - return do_eval_args(form, env, ctx_form, &lookup_var); -} - static val eval_args_lisp1(val form, val env, val ctx_form) { return do_eval_args(form, env, ctx_form, &lookup_sym_lisp1); @@ -1105,14 +1105,6 @@ static val op_lambda(val form, val env) return func_interp(env, form); } -static val op_call(val form, val env) -{ - val args = rest(form); - val func_form = first(args); - val func = eval(func_form, env, form); - return apply(func, eval_args(rest(args), env, form), form); -} - static val op_fun(val form, val env) { val name = second(form); @@ -3171,7 +3163,6 @@ void eval_init(void) reg_op(append_each_star_s, op_each); reg_op(let_star_s, op_let); reg_op(lambda_s, op_lambda); - reg_op(call_s, op_call); reg_op(fun_s, op_fun); reg_op(cond_s, op_cond); reg_op(if_s, op_if); @@ -3248,6 +3239,7 @@ void eval_init(void) reg_fun(intern(lit("mappend"), user_package), func_n1v(mappendv)); reg_fun(intern(lit("mappend*"), user_package), func_n1v(lazy_mappendv)); reg_fun(apply_s, func_n1v(apply_intrinsic)); + reg_fun(call_s, func_n1v(call)); reg_fun(intern(lit("reduce-left"), user_package), func_n4o(reduce_left, 2)); reg_fun(intern(lit("reduce-right"), user_package), func_n4o(reduce_right, 2)); diff --git a/txr.1 b/txr.1 index 2272a9a5..b54ce957 100644 --- a/txr.1 +++ b/txr.1 @@ -6620,26 +6620,18 @@ Optional arguments: [(lambda (x : y) (list x y)) 1] -> (1 nil) [(lambda (x : y) (list x y)) 1 2] -> (1 2) -.SS Operator call +.SS Function call .TP Syntax: - (call {}*) + (call *) .TP Description: -The call operator invokes a function. must evaluate -to a function. Each is evaluated in left to right -order and the resulting values are passed to the function as arguments. -The return value of the (call ...) expression is that of the function -applied to those arguments. - -The may be any Lisp form that produces a function -as its value: a symbol denoting a variable in which a function is stored, -a lambda expression, a function call which returns a function, -or (fun ...) expression. +The call function invokes , passing it the given +arguments, if any. .TP Examples: -- cgit v1.2.3