diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 76 |
1 files changed, 1 insertions, 75 deletions
@@ -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) |