diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-06-13 21:03:44 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-06-13 21:03:44 -0700 |
commit | 9b64a129d691fa3e4a08dacbd6e2c697bb4a857f (patch) | |
tree | 9f709e719577f9284f21c30ee1ca9899f14c260a | |
parent | ed73979d131383a082efa7d6e588ffe47464bb89 (diff) | |
download | txr-9b64a129d691fa3e4a08dacbd6e2c697bb4a857f.tar.gz txr-9b64a129d691fa3e4a08dacbd6e2c697bb4a857f.tar.bz2 txr-9b64a129d691fa3e4a08dacbd6e2c697bb4a857f.zip |
bugfix: autoload syntactic places.
TXR Lisp doesn't autoload the definition of places.
For instance if a (set (foo x) y) appears out of the
blue and foo is keyed for autoload, it doesn't happen.
The right place to fix this is to do the autload check
in the place macro expander, since every place form is
tried as a macro.
We need to expose the lisplib_try_load function as a Lisp
intrinsic.
* lisplib.c (lisplib_init): Register sys:try-load
intrinsic, mapped to lisplib_try_load.
* share/txr/stdlib/place.tl (sys:get-place-macro):
New function.
(sys:pl-expand): Use sys:get-place-macro instead of
direct lookup in *place-macro* hash. The new function
tries to autoload the symbol if it finds no place
macro for it.
-rw-r--r-- | lisplib.c | 1 | ||||
-rw-r--r-- | share/txr/stdlib/place.tl | 8 |
2 files changed, 7 insertions, 2 deletions
@@ -580,6 +580,7 @@ void lisplib_init(void) dlt_register(dl_table, error_instantiate, error_set_entries); dlt_register(dl_table, keyparams_instantiate, keyparams_set_entries); dlt_register(dl_table, ffi_instantiate, ffi_set_entries); + reg_fun(intern(lit("try-load"), system_package), func_n1(lisplib_try_load)); } val lisplib_try_load(val sym) diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 1ea1b95c..2e15118b 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -81,11 +81,15 @@ (makunbound ',',place-expr)))) ,*op-body)) + (defun sys:get-place-macro (sym) + (or [*place-macro* sym] + (progn (sys:try-load sym) [*place-macro* sym]))) + (defun sys:pl-expand (unex-place env) (while t (let ((place unex-place)) - (let ((pm-expander [*place-macro* (if (consp unex-place) - (car unex-place))])) + (let ((pm-expander (sys:get-place-macro (if (consp unex-place) + (car unex-place))))) (when pm-expander (sys:setq place (sys:set-macro-ancestor [pm-expander unex-place] |