summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-02 02:37:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-02 02:37:17 -0800
commit256ba9369ab15b1eced9aa81fd1e466e138e2933 (patch)
treec579e25cf5e1cd302755c486c66f742eef853099 /eval.c
parent97b07f495505f5e3b9b0e99e8d024d85eedf0952 (diff)
downloadtxr-256ba9369ab15b1eced9aa81fd1e466e138e2933.tar.gz
txr-256ba9369ab15b1eced9aa81fd1e466e138e2933.tar.bz2
txr-256ba9369ab15b1eced9aa81fd1e466e138e2933.zip
* eval.c (apply): Support string and vector arglist.
(do_eval_args): Support string or vector in dot position. * lib.c (tolist): New function. * lib.h (tolist): Declared. * txr.1: Document how apply and dot position in compound forms supports strings as well as vectors.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index 94332315..888c7e49 100644
--- a/eval.c
+++ b/eval.c
@@ -312,8 +312,13 @@ val apply(val fun, val arglist, val ctx_form)
type_check (fun, FUN);
- type_assert (listp(arglist),
- (lit("~s: arglist ~s is not a list"), car(ctx_form), arglist, nao));
+ if (!listp(arglist)) {
+ val arglist_conv = tolist(arglist);
+ type_assert (listp(arglist_conv),
+ (lit("~s: arglist ~s is not a list"), car(ctx_form),
+ arglist, nao));
+ arglist = arglist_conv;
+ }
variadic = fun->f.variadic;
fixparam = fun->f.fixparam;
@@ -430,9 +435,8 @@ static val do_eval_args(val form, val env, val ctx_form,
ptail = list_collect(ptail, do_eval(car(form), env, ctx_form, lookup));
if (form) {
val dotpos = do_eval(form, env, ctx_form, lookup);
- ptail = list_collect_append(ptail, if3(vectorp(dotpos),
- list_vector(dotpos),
- dotpos));
+ ptail = list_collect_append(ptail, if3(listp(dotpos),
+ dotpos, tolist(dotpos)));
}
return values;
}