diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-07-16 15:26:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-07-16 15:26:04 -0700 |
commit | d83e611d58441f546babd1d742926c191d416e58 (patch) | |
tree | f950e3ced1b56dee084696544d62a6468088ad40 /share | |
parent | 86f10aa563a75a4cce703970faf2940f4f537e13 (diff) | |
download | txr-d83e611d58441f546babd1d742926c191d416e58.tar.gz txr-d83e611d58441f546babd1d742926c191d416e58.tar.bz2 txr-d83e611d58441f546babd1d742926c191d416e58.zip |
global environment accessors can now create bindings.
The accessors symbol-value, symbol-function and symbol-macro
can now be used to store a value to nonexistent bindings,
which brings those bindings into existence.
* share/txr/stdlib/place.tl (sys:ge-fun-getter-setter,
sys:get-vb): Don't throw exceptions for nonexistent binding
lookups: create and return the bindings instead. For methods,
use static-slot-ensure rather than static-slot-set. Thus
new methods can be defined by setting to a (meth ...) place.
* txr.1: Doc updated.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/place.tl | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 63d855a9..5b22e589 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -809,20 +809,18 @@ (:postinit (cons (op struct-get-postinitfun struct) (op struct-set-postinitfun struct))) (t (cons (op static-slot struct slot) - (op static-slot-set struct slot)))) + (op static-slot-ensure struct slot)))) :)) ((type sym) (if (eq type 'macro) - (let ((cell (gethash sys:top-mb sym))) - (unless cell - (sys:eval-err "unbound macro ~s" sym)) + (let ((cell (or (gethash sys:top-mb sym) + (sethash sys:top-mb sym (cons sym nil))))) (cons (op cdr) (op sys:rplacd cell))) :)) (else - (let ((cell (gethash sys:top-fb sym))) - (unless cell - (sys:eval-err "unbound function ~s" sym)) + (let ((cell (or (gethash sys:top-fb sym) + (sethash sys:top-fb sym (cons sym nil))))) (cons (op cdr) (op sys:rplacd cell)))))) @@ -856,7 +854,7 @@ (defun sys:get-vb (sym) (or (gethash sys:top-vb sym) - (sys:eval-err "unbound variable ~s" sym))) + (sethash sys:top-vb sym (cons sym nil)))) (defplace (symbol-value sym-expr) body (getter setter |