diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-03-03 10:51:38 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-03-03 10:51:38 -0800 |
commit | 7f07e5ed29085c46144c0a2967c1827dc2645f22 (patch) | |
tree | 0be33183f8fe633c2d9a19f5e4f2cbebc8739bda /eval.c | |
parent | 94b999ab6e5ec11ed9b06a7c50f45cead6ded9fc (diff) | |
download | txr-7f07e5ed29085c46144c0a2967c1827dc2645f22.tar.gz txr-7f07e5ed29085c46144c0a2967c1827dc2645f22.tar.bz2 txr-7f07e5ed29085c46144c0a2967c1827dc2645f22.zip |
lambda expressions aren't fboundp.
We don't want (fboundp '(lambda ...)) to be true, or
(symbol-function '(lambda ...)) to yield a function.
This also fixes funny print formatting of lambda
expressions.
* eval.c (lookup_fun): Do not recognize lambda expressions.
Also, return nil for unknown syntax; don't bother looking
it up in the hashes.
(do_eval): We now have to check for a lambda expression in the
car position to evaluate it; lookup_fun will no longer do
that.
(op_fun): The interpreted fun oprator must also check for
lambda itself.
(do_expand): A small code change is required here to avoid
spuriously warning about a lambda in the car position.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -538,8 +538,8 @@ val lookup_fun(val env, val sym) } } else if (car(sym) == macro_s) { return lookup_mac(nil, cadr(sym)); - } else if (car(sym) == lambda_s) { - return cons(sym, func_interp(env, sym)); + } else { + return nil; } } return or2(gethash(top_fb, sym), @@ -1516,6 +1516,10 @@ static val do_eval(val form, val env, val ctx, debug_return (ret); } else { val fbinding = lookup_fun(env, oper); + + if (!fbinding && consp(oper) && car(oper) == lambda_s) + fbinding = cons(oper, func_interp(env, oper)); + if (!fbinding) { last_form_evaled = form; eval_error(form, lit("~s does not name a function or operator"), oper, nao); @@ -1834,6 +1838,9 @@ static val op_fun(val form, val env) val name = second(form); val fbinding = lookup_fun(env, name); + if (!fbinding && consp(name) && car(name) == lambda_s) + fbinding = cons(name, func_interp(env, name)); + if (!fbinding) eval_error(form, lit("no function exists named ~s"), name, nao); @@ -4855,10 +4862,9 @@ again: } } - if (consp(insym) && car(insym) == lambda_s) + if (consp(insym) && car(insym) == lambda_s) { insym_ex = expand(insym, menv); - - if (!lookup_fun(menv, sym) && !special_operator_p(sym)) { + } else if (!lookup_fun(menv, sym) && !special_operator_p(sym)) { if (!bindable(sym)) eval_warn(last_form_expanded, lit("~s appears in operator position"), sym, nao); |