diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-08 06:40:06 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-09-08 06:40:06 -0700 |
commit | 6752067fbbeb3813fe991a02c03dd26dd6aae1b0 (patch) | |
tree | 39ba05d27bdef9770eeae22af5af95442cf768b0 /share | |
parent | 97a17b79dd558c8ee8648a0acf2d50299e3c5125 (diff) | |
download | txr-6752067fbbeb3813fe991a02c03dd26dd6aae1b0.tar.gz txr-6752067fbbeb3813fe991a02c03dd26dd6aae1b0.tar.bz2 txr-6752067fbbeb3813fe991a02c03dd26dd6aae1b0.zip |
New slet macro.
* lisplib.c (place_set_entries): Add slet symbol to autoload
list for place.tl.
* share/txr/stdlib/place.tl (sys:r-s-let-expander): New
function.
(rlet): Replace body with call to sys:r-s-let-expander.
(slet): New macro.
* txr.1: Clarification and corrections in rlet description
and example. rlet will in fact handle the three-variable
rotation case because, since a is not a constant expression,
(rlet ((temp a)) ...) reduces to let.
Documented new slet.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/place.tl | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index bd2f47de..b0e1958f 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -115,16 +115,23 @@ (sys:eval-err "~s is not a deletable place" place))) (t (sys:eval-err "form ~s is not syntax denoting a deletable place" place))))) -(defmacro rlet (bindings :env e . body) - (let ((exp-bindings (mapcar (aret ^(,@1 ,(macroexpand @2 e))) bindings))) - (let ((renames [keep-if constantp exp-bindings second]) - (regular [remove-if constantp exp-bindings second])) +(macro-time + (defun sys:r-s-let-expander (bindings body e pred) + (let ((exp-bindings (mapcar (aret ^(,@1 ,(macroexpand @2 e))) bindings))) + (let ((renames [keep-if pred exp-bindings second]) + (regular [remove-if pred exp-bindings second])) (cond ((and renames regular) ^(symacrolet ,renames (let ,regular ,*body))) (renames ^(symacrolet ,renames ,*body)) (regular ^(let ,regular ,*body)) - (t ^(progn ,*body)))))) + (t ^(progn ,*body))))))) + +(defmacro rlet (bindings :env e . body) + [sys:r-s-let-expander bindings body e constantp]) + +(defmacro slet (bindings :env e . body) + (sys:r-s-let-expander bindings body e [orf constantp bindable])) (defmacro with-gensyms (syms . body) ^(let ,(zip syms (repeat '((gensym)))) ,*body)) |