diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-05-20 19:44:07 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-05-20 19:44:07 -0700 |
commit | e2437397f8f4430fd479cafe9495e5a19e970f86 (patch) | |
tree | b45cac8d1c9f26461d40b7a50744074cfeba618c | |
parent | d3221bbe79e7bb19cd5fab4138857af553ee9e7a (diff) | |
download | txr-e2437397f8f4430fd479cafe9495e5a19e970f86.tar.gz txr-e2437397f8f4430fd479cafe9495e5a19e970f86.tar.bz2 txr-e2437397f8f4430fd479cafe9495e5a19e970f86.zip |
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.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | eval.c | 20 | ||||
-rw-r--r-- | txr.1 | 16 |
3 files changed, 20 insertions, 26 deletions
@@ -1,3 +1,13 @@ +2014-05-20 Kaz Kylheku <kaz@kylheku.com> + + 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 <kaz@kylheku.com> Version 89 @@ -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)); @@ -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 <function-form> {<argument-form>}*) + (call <function> <argument>*) .TP Description: -The call operator invokes a function. <function-form> must evaluate -to a function. Each <argument-form> 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 <function-form> 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 <function>, passing it the given +arguments, if any. .TP Examples: |