summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-05-15 06:40:03 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-05-15 06:40:03 -0700
commitf1cb385c90eb80200c36fa2628e023958472ec39 (patch)
tree994aff54aa47dcc0feabb23eaf5b07462b6516dd /eval.c
parent47dd339b4ae661aca9773560d83072d649a88919 (diff)
downloadtxr-f1cb385c90eb80200c36fa2628e023958472ec39.tar.gz
txr-f1cb385c90eb80200c36fa2628e023958472ec39.tar.bz2
txr-f1cb385c90eb80200c36fa2628e023958472ec39.zip
* eval.c (symbol_value): Retrieve the binding of a symbol
macro also. (boundp): Return t for symbol macros. (makunbound, fmakunbound): New functions. (eval_init): Register makunbound and fmakunbound. * txr.1: Document changes to symbol-value and boundp, and add dialect notes about the different semantics of binding.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index beecc139..8a5b84df 100644
--- a/eval.c
+++ b/eval.c
@@ -3283,7 +3283,10 @@ static val mapdov(val fun, val list_of_lists)
static val symbol_value(val sym)
{
- return cdr(lookup_var(nil, sym));
+ uses_or2;
+
+ return cdr(or2(lookup_var(nil, sym),
+ lookup_symac(nil, sym)));
}
static val symbol_function(val sym)
@@ -3296,7 +3299,7 @@ static val symbol_function(val sym)
static val boundp(val sym)
{
- return if3(lookup_var(nil, sym), t, nil);
+ return if2(lookup_var(nil, sym) || lookup_symac(nil, sym), t);
}
static val fboundp(val sym)
@@ -3305,6 +3308,23 @@ static val fboundp(val sym)
gethash(op_table, sym), t);
}
+static val makunbound(val sym)
+{
+ lisplib_try_load(sym),
+ remhash(top_vb, sym);
+ remhash(top_smb, sym);
+ remhash(special, sym);
+ return sym;
+}
+
+static val fmakunbound(val sym)
+{
+ lisplib_try_load(sym),
+ remhash(top_fb, sym);
+ remhash(top_mb, sym);
+ return sym;
+}
+
static val rangev_func(val env, val lcons)
{
cons_bind (from, to_step, env);
@@ -4370,6 +4390,8 @@ void eval_init(void)
reg_fun(intern(lit("symbol-function"), user_package), func_n1(symbol_function));
reg_fun(intern(lit("boundp"), user_package), func_n1(boundp));
reg_fun(intern(lit("fboundp"), user_package), func_n1(fboundp));
+ reg_fun(intern(lit("makunbound"), user_package), func_n1(makunbound));
+ reg_fun(intern(lit("fmakunbound"), user_package), func_n1(fmakunbound));
reg_fun(intern(lit("func-get-form"), user_package), func_n1(func_get_form));
reg_fun(intern(lit("func-get-env"), user_package), func_n1(func_get_env));
reg_fun(intern(lit("func-set-env"), user_package), func_n2(func_set_env));