summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-09-27 08:06:47 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-09-27 08:06:47 -0700
commit70dca98f3500158716f49d5281d55769a44f7f67 (patch)
treea635c43c7710ec946e480f5fc287461c25f035f4 /eval.c
parent38868195bfc5df39c11e85df4e1550c197f32009 (diff)
downloadtxr-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.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/eval.c b/eval.c
index 714b86a1..7268f893 100644
--- a/eval.c
+++ b/eval.c
@@ -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);
}