From 2987f69f690d8433ad3aaa9e9f41949455ada2cb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 25 Oct 2011 23:04:48 -0400 Subject: * filter.c (function_filter): Function removed. (get_filter): Treat (:fun ...) syntax as a single function call with extra arguments, currying it up as curried function that invokes match_funcall once. * match.c (match_funcall): Extended to take a list of the additional arguments from get_filter. Adds these to the function call form generated for the v_func call. * match.h (match_funcall): Declaration updated. * txr.1: Function Filter additional arguments documented. --- match.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'match.c') diff --git a/match.c b/match.c index 49a0a125..5fe8782f 100644 --- a/match.c +++ b/match.c @@ -2819,14 +2819,17 @@ repeat_spec_same_data: return cons(c.bindings, if3(c.data, cons(c.data, c.data_lineno), t)); } -val match_funcall(val name, val arg) +val match_funcall(val name, val arg, val other_args) { cons_bind (in_spec, in_bindings, uw_get_match_context()); spec_bind (specline, spec_linenum, first_spec, in_spec); - val arg1_sym = make_sym(lit("arg1")), arg2_sym = make_sym(lit("arg2")); - val bindings = cons(cons(arg1_sym, arg), in_bindings); + val in_arg_sym = make_sym(lit("in_arg")); + val out_arg_sym = make_sym(lit("out_arg")); + val bindings = cons(cons(in_arg_sym, arg), in_bindings); val spec = cons(list(spec_linenum, - list(name, arg1_sym, arg2_sym, nao), nao), nil); + cons(name, + cons(in_arg_sym, cons(out_arg_sym, other_args))), + nao), nil); match_files_ctx nc; (void) first_spec; @@ -2834,17 +2837,17 @@ val match_funcall(val name, val arg) if (ret == nil) sem_error(spec_linenum, lit("filter: (~s ~s ~s) failed"), name, - arg, arg2_sym, nao); + arg, out_arg_sym, nao); if (ret == decline_k) sem_error(spec_linenum, lit("filter: function ~s not found"), name, nao); { - val out = assoc(nc.bindings, arg2_sym); + val out = assoc(nc.bindings, out_arg_sym); if (!out) sem_error(spec_linenum, lit("filter: (~s ~s ~s) did not bind ~s"), name, - arg, arg2_sym, arg2_sym, nao); + arg, out_arg_sym, out_arg_sym, nao); return cdr(out); } } -- cgit v1.2.3