diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-05-15 06:40:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-05-15 06:40:03 -0700 |
commit | f1cb385c90eb80200c36fa2628e023958472ec39 (patch) | |
tree | 994aff54aa47dcc0feabb23eaf5b07462b6516dd /eval.c | |
parent | 47dd339b4ae661aca9773560d83072d649a88919 (diff) | |
download | txr-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.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -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)); |