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 /txr.1 | |
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 'txr.1')
-rw-r--r-- | txr.1 | 33 |
1 files changed, 27 insertions, 6 deletions
@@ -27738,8 +27738,10 @@ in that .code rlet assumes that those .metn sym -s -which have constant -.metn init-form -s +whose +.metn init-form -s, +after macro expansion, +are constant expressions (according to the .code constantp function) may be safely implemented as a symbol macro rather than a lexical @@ -27753,16 +27755,16 @@ code with fewer temporary variables. On the other hand, .code rlet -is not suitable in situations when true variables are required, which +is not suitable in some situations when true variables are required, which are assignable, and provide temporary storage. .TP* "Example:" .cblk ;; WRONG! Exchange two variables, a and b: - (rlet ((temp a)) - (set a b) - (set b temp)) + (rlet ((flag nil)) + ;; code which mutates flag + (flip flag)) ;; error: flag macro-expands to nil ;; Demonstration of constant-propagation (let ((a 42)) @@ -27791,6 +27793,25 @@ turning the expression into .codn "(+ 1 y)" . +.coNP Macro @ slet +.synb +.mets (slet >> ({( sym << init-form )}*) << body-form *) +.syne +.desc +The macro +.code slet +a weaker form of the +.code rlet +macro. Just like +.codn rlet , +.code slet +reduces bindings initialized by constant expressions +to symbol macros. In addition, unlike +.codn rlet , +.code slet +also reduces to symbol macros those bindings which +are initialized by symbol expressions (values of variables). + .coNP Macro @ define-accessor .synb .mets (define-accessor < get-function << set-function ) |