diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-09-27 08:06:47 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-09-27 08:06:47 -0700 |
commit | 70dca98f3500158716f49d5281d55769a44f7f67 (patch) | |
tree | a635c43c7710ec946e480f5fc287461c25f035f4 /eval.c | |
parent | 38868195bfc5df39c11e85df4e1550c197f32009 (diff) | |
download | txr-70dca98f3500158716f49d5281d55769a44f7f67.tar.gz txr-70dca98f3500158716f49d5281d55769a44f7f67.tar.bz2 txr-70dca98f3500158716f49d5281d55769a44f7f67.zip |
symbol-function: support lambda expressions.
* eval.c (lookup_fun): Check for a lambda expression and
return a faked binding containing the interpreted function.
(do_eval, op_fun): Remove checks for lambda that are now
being done in lookup_fun. In many other places where
lookup_fun is used, we still need lambda checks, like
in the expander.
* share/txr/stdlib/place.tl (sys:get-fun-getter-setter): Take
form argument. Diagnose assignments to lambda, and to unknown
function place syntax.
(defplace symbol-function): Pass sys:*pl-form* to
sys:get-fun-getter-setter as form argument.
* txr.1: fboundp and symbol-function doc updated.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -550,6 +550,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; } @@ -1532,9 +1534,6 @@ static val do_eval(val form, val env, val ctx, } 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); @@ -1855,11 +1854,8 @@ static val op_fun(val form, val env) val name = second(form); val fbinding = lookup_fun(env, name); - if (!fbinding) { - if (consp(name) && car(name) == lambda_s) - return func_interp(env, name); + if (!fbinding) eval_error(form, lit("no function exists named ~s"), name, nao); - } return cdr(fbinding); } |