summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-01-22 23:39:45 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-01-22 23:39:45 -0800
commit9fa70b67bad4f95c22fa0e7a1148b88c82f375e1 (patch)
treefaeb229bbdf434c599a7ddaf2e09e8a48d32475a /eval.c
parent8ced687d65438141be8a1305fa4058a76fa3cc59 (diff)
downloadtxr-9fa70b67bad4f95c22fa0e7a1148b88c82f375e1.tar.gz
txr-9fa70b67bad4f95c22fa0e7a1148b88c82f375e1.tar.bz2
txr-9fa70b67bad4f95c22fa0e7a1148b88c82f375e1.zip
Changes to the list collection mechanism to improve
the extension of list operations over vectors and strings. * eval.c (do_eval_args, bindings_helper, op_each, subst_vars, supplement_op_syms, mapcarv, mappendv): Switch from list_collect_* macros to functions. * lib.c (copy_list): Switch from list_collect* macros to functions. Use list_collect_nconc for the final terminator. Doing a copy there with list_collect_append was actually wasteful, and now that list_collect_append calls copy_list in places, it triggered runaway recursion. (make_like): Bugfix: list_vector was used instead of vector_list. (to_seq, list_collect, list_collect_nconc, list_collect_append): New functions. (append2, appendv, nappend2, sub_list, replace_list, ldiff, remq, remql, remqual, remove_if, keep_if, proper_plist_to_alist, improper_plist_to_alist, split_str, split_str_set, tok_str, list_str, chain, andf, orf, lis_vector, mapcar, mapcon, mappend, merge, set_diff, env): Switch from list_collect* macros to functions. (replace_str, replace_vec): Allow single item replacement sequence. * lib.h (to_seq): Declared. (list_collect, list_collect_nconc, list_collect_append): Macros removed, replaced by function declarations of the same name. These functions return the new ptail since they cannot assign to it, requiring all uses to be updated to do the assignment of the returned value. (list_collect_decl): Use val rather than obj_t *. * match.c (vars_to_bindings, h_coll, subst_vars, extract_vars, extract_bindings, do_output_line, do_output, v_gather, v_collect): Switch from list_collect* macros to functions. * parser.y (o_elems_transform): Likewise. * regex.c (dv_compile_regex, regsub): Likewise. * txr.c (txr_main): Likewise.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/eval.c b/eval.c
index 85233904..5ea361d8 100644
--- a/eval.c
+++ b/eval.c
@@ -414,9 +414,9 @@ static val do_eval_args(val form, val env, val ctx_form,
{
list_collect_decl (values, ptail);
for (; consp(form); form = cdr(form))
- list_collect(ptail, do_eval(car(form), env, ctx_form, lookup));
+ ptail = list_collect(ptail, do_eval(car(form), env, ctx_form, lookup));
if (form)
- list_collect_append(ptail, do_eval(form, env, ctx_form, lookup));
+ ptail = list_collect_append(ptail, do_eval(form, env, ctx_form, lookup));
return values;
}
@@ -582,7 +582,7 @@ static val bindings_helper(val vars, val env, val sequential, val ctx_form)
car(ctx_form), var, nao);
}
- list_collect (ptail, cons(var, val));
+ ptail = list_collect (ptail, cons(var, val));
if (sequential)
env_replace_vbind(nenv, new_bindings);
@@ -645,9 +645,9 @@ static val op_each(val form, val env)
{
val res = eval_progn(body, make_env(new_bindings, nil, env), form);
if (collect)
- list_collect(ptail, res);
+ ptail = list_collect(ptail, res);
else if (append)
- list_collect_nconc(ptail, res);
+ ptail = list_collect_nconc(ptail, res);
}
}
@@ -1291,7 +1291,7 @@ static val subst_vars(val forms, val env)
continue;
} else if (sym == quasi_s) {
val nested = subst_vars(rest(form), env);
- list_collect_append(iter, nested);
+ iter = list_collect_append(iter, nested);
forms = cdr(forms);
continue;
} else if (sym == expr_s) {
@@ -1300,7 +1300,7 @@ static val subst_vars(val forms, val env)
continue;
} else {
val nested = subst_vars(form, env);
- list_collect_append(iter, nested);
+ iter = list_collect_append(iter, nested);
forms = cdr(forms);
continue;
}
@@ -1320,7 +1320,7 @@ static val subst_vars(val forms, val env)
form, nao);
}
- list_collect(iter, form);
+ iter = list_collect(iter, form);
forms = cdr(forms);
}
@@ -1604,8 +1604,8 @@ static val supplement_op_syms(val ssyms, val max)
val num = car(entry);
for (; lt(ni, num); ni = plus(ni, one))
- list_collect(tl, cons(ni, gensym(format_op_arg(ni))));
- list_collect(tl, entry);
+ tl = list_collect(tl, cons(ni, gensym(format_op_arg(ni))));
+ tl = list_collect(tl, entry);
}
return outsyms;
@@ -1838,11 +1838,11 @@ val mapcarv(val fun, val list_of_lists)
val list = car(iter);
if (!list)
return make_like(out, list_orig);
- list_collect(atail, car(list));
+ atail = list_collect(atail, car(list));
*car_l(iter) = cdr(list);
}
- list_collect(otail, apply(fun, args, nil));
+ otail = list_collect(otail, apply(fun, args, nil));
}
}
}
@@ -1864,11 +1864,11 @@ static val mappendv(val fun, val list_of_lists)
val list = car(iter);
if (!list)
return make_like(out, list_orig);
- list_collect(atail, car(list));
+ atail = list_collect(atail, car(list));
*car_l(iter) = cdr(list);
}
- list_collect_append (otail, apply(fun, args, nil));
+ otail = list_collect_append(otail, apply(fun, args, nil));
}
}
}