summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-10 22:48:34 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-10 22:48:34 -0800
commitc58a1a16de19700543700b24dd42dd3c234493b7 (patch)
tree931d74c98ebb9c5f76ab93ea1df67863700ee85a /eval.c
parent8220c2ea55a59bee7bfdef3b5c9b180005ef95ee (diff)
downloadtxr-c58a1a16de19700543700b24dd42dd3c234493b7.tar.gz
txr-c58a1a16de19700543700b24dd42dd3c234493b7.tar.bz2
txr-c58a1a16de19700543700b24dd42dd3c234493b7.zip
symbol-function semantics change; new symbol-macro.
* eval.c (symbol_function): Only retrieve function binding, and not macro or operator bindings, unless compatibility <= 127 is in effect. (symbol_macro): New function. (fboundp): Only test for existence of function, not macro or operator, unless <= 127 compatibility is in effect. (fmakunbound): Do not remove macro binding, unless compatibility <= 127 is in effect. (eval_init): Register sys:top-mb variable for use in place.tl library module. Register symbol-macro intrinsic function. * share/txr/stdlib/place.tl (sys:get-mb): New function (symbol-macro): New syntactic place. * txr.1: Updated incorrect documentation about environments from the perspective that macros and functions coexist. Documented symbol-macro. Updated symbol-function, fboundp and fmakunbound documentation. Added missing documentation for mmakunbound. Reference to fboundp under define-place-macro revised to mboundp. Added compatibility notes.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 7ee210a5..07ce4ff6 100644
--- a/eval.c
+++ b/eval.c
@@ -3693,9 +3693,17 @@ static val symbol_value(val sym)
static val symbol_function(val sym)
{
uses_or2;
- return or2(or2(cdr(lookup_fun(nil, sym)),
- cdr(lookup_mac(nil, sym))),
- gethash(op_table, sym));
+
+ if (opt_compat && opt_compat <= 127)
+ return or2(or2(cdr(lookup_fun(nil, sym)),
+ cdr(lookup_mac(nil, sym))),
+ gethash(op_table, sym));
+ return cdr(lookup_fun(nil, sym));
+}
+
+static val symbol_macro(val sym)
+{
+ return cdr(lookup_mac(nil, sym));
}
val boundp(val sym)
@@ -3705,8 +3713,10 @@ val boundp(val sym)
val fboundp(val sym)
{
- return if2(lookup_fun(nil, sym) || lookup_mac(nil, sym) ||
- gethash(op_table, sym), t);
+ if (opt_compat && opt_compat <= 127)
+ return if2(lookup_fun(nil, sym) || lookup_mac(nil, sym) ||
+ gethash(op_table, sym), t);
+ return tnil(lookup_fun(nil, sym));
}
static val mboundp(val sym)
@@ -3732,7 +3742,8 @@ static val fmakunbound(val sym)
{
lisplib_try_load(sym),
remhash(top_fb, sym);
- remhash(top_mb, sym);
+ if (opt_compat && opt_compat <= 127)
+ remhash(top_mb, sym);
return sym;
}
@@ -4984,8 +4995,10 @@ void eval_init(void)
reg_varl(intern(lit("top-vb"), system_package), top_vb);
reg_varl(intern(lit("top-fb"), system_package), top_fb);
+ reg_varl(intern(lit("top-mb"), system_package), top_mb);
reg_fun(intern(lit("symbol-value"), user_package), func_n1(symbol_value));
reg_fun(intern(lit("symbol-function"), user_package), func_n1(symbol_function));
+ reg_fun(intern(lit("symbol-macro"), user_package), func_n1(symbol_macro));
reg_fun(intern(lit("boundp"), user_package), func_n1(boundp));
reg_fun(intern(lit("fboundp"), user_package), func_n1(fboundp));
reg_fun(intern(lit("mboundp"), user_package), func_n1(mboundp));