diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-04-17 20:12:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-04-17 20:12:21 -0700 |
commit | 4d68e3c2f2162a7c513c5c2c4a3c7c2c22a9e3be (patch) | |
tree | cfb9b186eef136759a4d21ffd2e6655099f529c5 | |
parent | 00c8f50d4e3bc6b7883f022ef3649d0a6167f4c7 (diff) | |
download | txr-4d68e3c2f2162a7c513c5c2c4a3c7c2c22a9e3be.tar.gz txr-4d68e3c2f2162a7c513c5c2c4a3c7c2c22a9e3be.tar.bz2 txr-4d68e3c2f2162a7c513c5c2c4a3c7c2c22a9e3be.zip |
Rebind *expand-hook* in load and compile-file.
* eval.c (loadv): Rebind *expand-hook* to its current
value, like we do with *package*.
* match.c (v_load): Likewise.
* stdlib/compiler.tl (compile-file-conditionally):
Likewise.
* txr.1: Documented.
-rw-r--r-- | eval.c | 1 | ||||
-rw-r--r-- | match.c | 1 | ||||
-rw-r--r-- | stdlib/compiler.tl | 1 | ||||
-rw-r--r-- | txr.1 | 42 |
4 files changed, 41 insertions, 4 deletions
@@ -4869,6 +4869,7 @@ val loadv(val target, varg load_args) env_vbind(dyn_env, load_recursive_s, t); env_vbind(dyn_env, load_hooks_s, nil); env_vbind(dyn_env, package_s, cur_package); + env_vbind(dyn_env, expand_hook_s, expand_hook); env_vbind(dyn_env, load_args_s, args_get_list(load_args)); if (txr_lisp_p == t) { @@ -4715,6 +4715,7 @@ static val v_load(match_files_ctx *c) env_vbind(dyn_env, load_path_s, name); env_vbind(dyn_env, load_recursive_s, t); env_vbind(dyn_env, package_s, cur_package); + env_vbind(dyn_env, expand_hook_s, expand_hook); if (!txr_lisp_p) { int gc = gc_state(0); diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index 98232c7b..b516d91a 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -2579,6 +2579,7 @@ (remove-path (caddr streams)))))) (let* ((err-ret (gensym)) (*package* *package*) + (*expand-hook* *expand-hook*) (*emit* t) (*eval* t) (*load-path* (stream-get-prop (car streams) :name)) @@ -9307,8 +9307,11 @@ directives bind the variable to the path of the loaded file just before parsing syntax from it, The .code *package* -variable is also given a new dynamic binding, whose value is the -same as the existing binding. These bindings are removed when the +and +.code *expand-hook* +variables are also given new dynamic bindings, whose values are, +propagated from their respective existing bindings. +These bindings are removed when the load operation completes, restoring the prior values of these variables. The @@ -44145,6 +44148,18 @@ is provided which encapsulates this logic. It allows a hook to easily insert itself before the other hooks, as recommended above, or after the other hooks. +The +.code load +function as well as the +.dir load +and +.dir include +directives in the Pattern Language create a new dynamic binding for +.code *expand-hook* +with the same value as the current value. Therefore, if a file being +loaded alters the value of the variable, the change will be undone +when the load operation terminates. + .TP* Example .verb @@ -70398,6 +70413,18 @@ home package matches the current package, it is printed without a package prefix. (Keyword symbols are always printed with the colon prefix, even if the keyword package is current.) +The +.code load +function as well as the +.dir load +and +.dir include +directives in the Pattern Language create a new dynamic binding for +.code *package* +with the same value as the current value. Therefore, if a file being +loaded alters the value of the variable, the change will be undone +when the load operation terminates. + .coNP Function @ make-sym .synb .mets (make-sym << name ) @@ -85182,6 +85209,12 @@ loaded file has the effect of altering the value of .codn *package* , that effect will be undone when the binding is removed after the load completes. + +.coIP *expand-hook* +is given a new dynamic binding, whose value is the same as its +existing binding. The above remarks made about +.code *package* +apply to this variable also. .RE .IP @@ -93862,9 +93895,10 @@ suffix. The .code compile-file function binds the variables -.code *load-path* -and +.codn *load-path* , .code *package* +and +.code *expand-hook* similarly to the .code load function. |