diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-11-25 20:45:50 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-11-25 20:45:50 -0800 |
commit | fc68528cf5a7714848d1f4c6ba855b763c49a85e (patch) | |
tree | 86f6e52093b071e7ea56a27dc335f1e9ffd2c9d1 | |
parent | 668209ba08049f1be25d8e5fec282df659c88aab (diff) | |
download | txr-fc68528cf5a7714848d1f4c6ba855b763c49a85e.tar.gz txr-fc68528cf5a7714848d1f4c6ba855b763c49a85e.tar.bz2 txr-fc68528cf5a7714848d1f4c6ba855b763c49a85e.zip |
Bugfix: sethash doesn't return stored value.
sethash mistakenly returns a boolean which indicates that the
value was newly added, rather than the documented behavior of
returning the new value.
* hash.c (sethash): return value rather than new_p.
* share/txr/stdlib/place.tl (defplace): The defplace form
now seturn the main symbol of the place being defined,
rather than returning whatever the last sethash call
returns.
(define-place-macro): Likewise.
(sys:register-simple-accessor): Likewise, so that defaccessor
returns the getter function's name.
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | share/txr/stdlib/place.tl | 18 |
2 files changed, 12 insertions, 8 deletions
@@ -626,7 +626,7 @@ val sethash(val hash, val key, val value) { val new_p; rplacd(gethash_c(hash, key, mkcloc(new_p)), value); - return new_p; + return value; } val pushhash(val hash, val key, val value) diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 81a506a5..29c8e1fa 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -312,15 +312,18 @@ ^((sethash *place-delete-expander* ',name (lambda (,deleter-sym ,place ,body-sym) (tree-bind ,args (cdr ,place) - ,delete-body))))))))) + ,delete-body))))) + ',name)))) (defmacro define-place-macro (name place-destructuring-args . body) (with-gensyms (name-dummy args) - ^(sethash *place-macro* ',name - (lambda (,args) - (mac-param-bind ,args - (,name-dummy ,*place-destructuring-args) - ,args ,*body))))) + ^(progn + (sethash *place-macro* ',name + (lambda (,args) + (mac-param-bind ,args + (,name-dummy ,*place-destructuring-args) + ,args ,*body))) + ',name))) (defplace (sys:var arg) body (getter setter @@ -666,7 +669,8 @@ (lambda (ssetter place body) ^(macrolet ((,ssetter (val) ^(,',set-fun ,*(cdr ',place) ,val))) - ,body)))) + ,body))) + get-fun) (defmacro define-accessor (get-fun set-fun) ^(sys:register-simple-accessor ',get-fun ',set-fun)) |