summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-26 08:40:22 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-11-26 08:40:22 -0800
commitdf9f85b3b720a9ebf7381b2cad7a9680ad0e31bf (patch)
treec7075648f15fda21e1eb313421206c4b8828f381 /eval.c
parent1f959abcf7cc1d18401d440b42761ac0b1babb78 (diff)
downloadtxr-df9f85b3b720a9ebf7381b2cad7a9680ad0e31bf.tar.gz
txr-df9f85b3b720a9ebf7381b2cad7a9680ad0e31bf.tar.bz2
txr-df9f85b3b720a9ebf7381b2cad7a9680ad0e31bf.zip
bugfix: quasilit read/print consistency, part 1.
The bug is that `@@@a` prints as `@@a` which reads as a different object. In this patch we simplify how quasiliterals are represented. Embedded expressions are no longer (sys:expr E), just E. Meta-numbers N and variables V are still (sys:var N). However `@@a` and `@a` remain equivalent. * eval.c (subst_vars): No need to look for expr_s; just evaluate a compound form. The recursive nested case is unnecessary and is removed. (expand_quasi): Do nothandle expr_s; it is not part of the quasi syntax any more. * lib.c (out_quasi_str): Do not look for expr_s in the quasi syntax; just print any expression with a @ the fallback case. * match.c (tx_subst_vars): Analogous changes to those done in subst_vars in eval.c. * parser.y (quasi_meta_helper): Static function removed. This was responsible for the issue due to stripping a level of meta from expressions already having a meta on them. (quasi_item): In the `@` n_expr syntax case, no longer call quasi_meta_helper. The remaining logic is simple enough to put in line. Symbols and integers get wrapped with (sys:var ...); other expressions are integrated into the syntax as-is.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/eval.c b/eval.c
index a5f74b5a..6fe12132 100644
--- a/eval.c
+++ b/eval.c
@@ -2365,19 +2365,14 @@ val subst_vars(val forms, val env, val filter)
iter = list_collect_append(iter, nested);
forms = cdr(forms);
continue;
- } else if (sym == expr_s) {
- val str = eval(rest(form), env, form);
+ } else {
+ val str = eval(form, env, form);
if (listp(str))
str = cat_str(mapcar(func_n1(tostringp), str), lit(" "));
else if (!stringp(str))
str = tostringp(str);
forms = cons(filter_string_tree(filter, tostringp(str)), rest(forms));
continue;
- } else {
- val nested = subst_vars(form, env, filter);
- iter = list_collect_append(iter, nested);
- forms = cdr(forms);
- continue;
}
} else if (bindable(form)) {
forms = cons(cons(var_s, cons(form, nil)), cdr(forms));
@@ -2983,12 +2978,8 @@ static val expand_quasi(val quasi_forms, val menv)
if (consp(form)) {
val sym = car(form);
- if (sym == expr_s) {
- val expr_ex = expand(rest(form), menv);
- if (expr_ex != rest(form))
- form_ex = rlcp(cons(sym, expr_ex), form);
- } else if (sym == var_s) {
+ if (sym == var_s) {
val param = second(form);
val mods = third(form);
val param_ex = expand(param, menv);