diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-12-27 20:25:49 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-12-27 20:25:49 -0800 |
commit | f5a48f7de36c0bbfb29da51af13bec2ed5a9ca7f (patch) | |
tree | ae5fbeed30b4c0936cbacddcca8202e73648df35 /share | |
parent | b2eb4ca71d4b85df0cef4aa354334ba867d2cfe2 (diff) | |
download | txr-f5a48f7de36c0bbfb29da51af13bec2ed5a9ca7f.tar.gz txr-f5a48f7de36c0bbfb29da51af13bec2ed5a9ca7f.tar.bz2 txr-f5a48f7de36c0bbfb29da51af13bec2ed5a9ca7f.zip |
Adding with-slots macro.
* lisplib.c (place_set_entries): Add with-slots to autoload
name list.
* share/txr/stdlib/struct.tl (with-slots): New macro.
* txr.1: Documented.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/struct.tl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl index c9d19e91..bc463274 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -236,3 +236,12 @@ (defmacro defmeth (type-sym name arglist . body) ^(sys:defmeth ',type-sym ',name (lambda ,arglist (block ,name ,*body)))) + +(defmacro with-slots ((. slot-specs) obj-expr . body) + (with-gensyms (obj-sym) + ^(let ((,obj-sym ,obj-expr)) + (symacrolet (,*(mapcar [iff consp + (aret ^(,@1 (slot ,obj-sym ',@2))) + (ret ^(,@1 (slot ,obj-sym ',@1)))] + slot-specs)) + ,*body)))) |