summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-06 00:39:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-06 00:39:17 -0800
commit6a63a6b32065f6a5839571b378605f875f9c5240 (patch)
tree3ffb3de049fdcefeed5f7a11cab48602729f95c5 /eval.c
parent87ef0e20b4e9d8f82d061ddc6993d04a2f6eda9d (diff)
downloadtxr-6a63a6b32065f6a5839571b378605f875f9c5240.tar.gz
txr-6a63a6b32065f6a5839571b378605f875f9c5240.tar.bz2
txr-6a63a6b32065f6a5839571b378605f875f9c5240.zip
* eval.c (op_dwim): Gutted down to just a few lines.
Basically the dwim operator is just a Lisp-1 version of the call operator now. It doesn't have to do anything funny with non-function objects, since they are callable. * lib.c (chr_str, chr_str_set, vecref, vecref_l): Replace inappropriate internal assertions with error exceptions. * unwind.h (numeric_assert, range_bug_unless): Unused macros removed.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c76
1 files changed, 1 insertions, 75 deletions
diff --git a/eval.c b/eval.c
index a70d8474..c469adf4 100644
--- a/eval.c
+++ b/eval.c
@@ -1224,81 +1224,7 @@ static val op_dwim(val form, val env)
{
val obj = eval_lisp1(second(form), env, form);
val args = eval_args_lisp1(rest(rest(form)), env, form);
-
- switch (type(obj)) {
- case NIL:
- return nil;
- case LIT:
- case STR:
- case LSTR:
- if (rest(args))
- eval_error(form, lit("[~s ...]: string indexing needs one arg"),
- obj, nao);
- {
- val index = first(args);
- if (consp(index)) {
- return sub_str(obj, car(index), cdr(index));
- } else {
- return chr_str(obj, first(args));
- }
- }
- case SYM:
- {
- val fbinding = lookup_fun(env, obj);
-
- if (!fbinding)
- eval_error(form, lit("[~s ...]: no function exists named ~s"),
- obj, obj, nao);
-
- return apply(cdr(fbinding), args, form);
- }
- case FUN:
- return apply(obj, args, form);
- case VEC:
- if (rest(args))
- eval_error(form, lit("[~s ...]: vector indexing needs one arg"),
- obj, nao);
- {
- val index = first(args);
-
- if (consp(index)) {
- return sub_vec(obj, car(index), cdr(index));
- } else {
- return vecref(obj, first(args));
- }
- }
- case CONS:
- case LCONS:
- if (rest(args))
- eval_error(form, lit("[~s ...]: list indexing needs one arg"),
- obj, nao);
- {
- val index = first(args);
- if (!bignump(index) && !fixnump(index) && !consp(index))
- eval_error(form, lit("[~s ~s]: index must be integer or pair"),
- obj, index, nao);
-
- if (consp(index)) {
- return sub_list(obj, car(index), cdr(index));
- } else {
- return listref(obj, first(args));
- }
- }
- case COBJ:
- {
- if (hashp(obj)) {
- if (lt(length(args), one))
- eval_error(form, lit("[~s ...]: hash indexing needs at least one arg"),
- obj, nao);
- return gethash_n(obj, first(args), second(args));
- }
- }
- /* fallthrough */
- default:
- eval_error(form, lit("object ~s not supported by [] notation"), obj, nao);
- }
-
- return nil;
+ return apply(obj, args, form);
}
static val op_catch(val form, val env)