summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval.c34
-rw-r--r--txr.16
2 files changed, 30 insertions, 10 deletions
diff --git a/eval.c b/eval.c
index ed87549b..82afee1c 100644
--- a/eval.c
+++ b/eval.c
@@ -149,20 +149,34 @@ static val make_env_intrinsic(val vbindings, val fbindings, val up_env)
val env_fbind(val env, val sym, val fun)
{
- val cell;
- type_check(env, ENV);
- cell = acons_new_c(sym, nulloc, mkloc(env->e.fbindings, env));
- rplacd(cell, fun);
- return cell;
+ if (env) {
+ val cell;
+ type_check(env, ENV);
+ cell = acons_new_c(sym, nulloc, mkloc(env->e.fbindings, env));
+ return rplacd(cell, fun);
+ } else {
+ val hcell = gethash_c(top_fb, sym, nulloc);
+ val cell = cdr(hcell);
+ if (cell)
+ return rplacd(cell, fun);
+ return sys_rplacd(hcell, cons(sym, fun));
+ }
}
val env_vbind(val env, val sym, val obj)
{
- val cell;
- type_check(env, ENV);
- cell = acons_new_c(sym, nulloc, mkloc(env->e.vbindings, env));
- rplacd(cell, obj);
- return cell;
+ if (env) {
+ val cell;
+ type_check(env, ENV);
+ cell = acons_new_c(sym, nulloc, mkloc(env->e.vbindings, env));
+ return rplacd(cell, obj);
+ } else {
+ val hcell = gethash_c(top_vb, sym, nulloc);
+ val cell = cdr(hcell);
+ if (cell)
+ return rplacd(cell, obj);
+ return sys_rplacd(hcell, cons(sym, obj));
+ }
}
static void env_vb_to_fb(val env)
diff --git a/txr.1 b/txr.1
index eb2f379a..9585fdaf 100644
--- a/txr.1
+++ b/txr.1
@@ -14245,6 +14245,12 @@ already exists in the environment, in the given space, then its
value is updated with
.codn value .
+If
+.meta env
+is specified as
+.codn nil ,
+then the binding takes place in the global environment.
+
.SS* Global Environment
.coNP Accessors @, symbol-function @ symbol-macro and @ symbol-value
.synb