From f5c845e6bfbdab362ce8d81dd9ae2a89dac7d213 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 28 Aug 2016 21:57:07 -0700 Subject: Fix bugs in new quasiquote optimization. * eval.c (qquote_init): Stricter quote_form_p_f test function: reject the quote form if it isn't a proper list of two elements. (optimize_qquote_form): Extract all arguments of list forms and catenate them with mapcan, rather than assuming that they have one argument. This wrong assumption breaks ,,*(list ...) interpolation, for instance. --- eval.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eval.c b/eval.c index 1368a422..3f4f606b 100644 --- a/eval.c +++ b/eval.c @@ -2635,6 +2635,8 @@ static void qquote_init(void) chain(car_f, eq_to_list_f, nao), nao); quote_form_p_f = andf(consp_f, + chain(cdr_f, consp_f, nao), + chain(cdr_f, cdr_f, null_f, nao), chain(car_f, eq_to_quote_f, nao), nao); xform_listed_quote_f = iffi(andf(consp_f, @@ -2663,12 +2665,12 @@ static val optimize_qquote_form(val form) if (all_satisfy(args, list_form_p_f, nil)) { sym = list_s; - args = mapcar(second_f, args); + args = mappend(cdr_f, args); } else { val blargs = butlast(args); if (all_satisfy(blargs, list_form_p_f, nil)) - return rlcp_tree(cons(list_star_s, nappend2(mapcar(second_f, blargs), + return rlcp_tree(cons(list_star_s, nappend2(mappend(cdr_f, blargs), last(args))), form); } } -- cgit v1.2.3