summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisplib.c4
-rw-r--r--share/txr/stdlib/ifa.tl3
-rw-r--r--txr.117
3 files changed, 23 insertions, 1 deletions
diff --git a/lisplib.c b/lisplib.c
index abdd8c1c..d5f0d1d1 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -106,7 +106,9 @@ static val ver_instantiate(val set_fun)
static val ifa_set_entries(val dlt, val fun)
{
- val name[] = { lit("ifa"), lit("conda"), lit("condlet"), nil };
+ val name[] = {
+ lit("ifa"), lit("whena"), lit("conda"), lit("condlet"), nil
+ };
set_dlt_entries(dlt, name, fun);
return nil;
}
diff --git a/share/txr/stdlib/ifa.tl b/share/txr/stdlib/ifa.tl
index 170e8eb5..e99d5d40 100644
--- a/share/txr/stdlib/ifa.tl
+++ b/share/txr/stdlib/ifa.tl
@@ -66,6 +66,9 @@
(if (,sym ,*(if (eq 'dwim sym) ^(,(second test)))
,*temps) ,then ,else)))))))))
+(defmacro whena (test . body)
+ ^(ifa ,test (progn ,*body)))
+
(macro-time
(defun sys:if-to-cond (if-oper cond-oper pairs)
(tree-case pairs
diff --git a/txr.1 b/txr.1
index 65c6c940..9bdc0cd4 100644
--- a/txr.1
+++ b/txr.1
@@ -14283,6 +14283,23 @@ as well as the anaphoric
.code it
variable feature.
+.coNP Macro @ whena
+.synb
+.mets (whena < test << form *)
+.syne
+.desc
+The
+.code whena
+macro is similar to the
+.code when
+macro, except that it is anaphoric in exactly the same manner as the
+.code ifa
+macro. It may be understood as conforming to the following equivalence:
+
+.cblk
+ (whena x f0 f2 ...) <--> (if x (progn f0 f2 ...))
+.cble
+
.coNP Macro @ dotimes
.synb
.mets (dotimes >> ( var < count-form <> [ result-form ]) << body-form *)