summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-03-21 21:48:05 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-03-21 21:48:05 -0700
commitc140bac5b058935e550b0d19fadd7dd822ce9f7a (patch)
treea6c8965d7cf5512bb7373003e7ae36a43b79e91a
parentc12706b1d801814af4a5efd327dac9adc4f99e9f (diff)
downloadtxr-c140bac5b058935e550b0d19fadd7dd822ce9f7a.tar.gz
txr-c140bac5b058935e550b0d19fadd7dd822ce9f7a.tar.bz2
txr-c140bac5b058935e550b0d19fadd7dd822ce9f7a.zip
New function: ignore, synonym of nilf.
This will be an official mechanism for indicating deliberately unused variables. * eval.c (eval_init): Register ignore intrinsic, binding to the same function object as nilf. * stdlib/compiler.tl (%const-foldable-funs%): Mention ignore function, next to its nilf synonym. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
-rw-r--r--eval.c7
-rw-r--r--stdlib/constfun.tl2
-rw-r--r--stdlib/doc-syms.tl5
-rw-r--r--txr.123
4 files changed, 32 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index e09db92a..343ea49f 100644
--- a/eval.c
+++ b/eval.c
@@ -7160,7 +7160,12 @@ void eval_init(void)
reg_fun(intern(lit("callf"), user_package), func_n1v(callf));
reg_fun(intern(lit("mapf"), user_package), func_n1v(mapf));
reg_fun(intern(lit("tf"), user_package), func_n0v(tf));
- reg_fun(intern(lit("nilf"), user_package), func_n0v(nilf));
+
+ {
+ val nilf_f = func_n0v(nilf);
+ reg_fun(intern(lit("nilf"), user_package), nilf_f);
+ reg_fun(intern(lit("ignore"), user_package), nilf_f);
+ }
reg_fun(intern(lit("print"), user_package), func_n3o(print, 1));
reg_fun(intern(lit("pprint"), user_package), func_n2o(pprint, 1));
diff --git a/stdlib/constfun.tl b/stdlib/constfun.tl
index bef32cc5..0f66ac41 100644
--- a/stdlib/constfun.tl
+++ b/stdlib/constfun.tl
@@ -47,7 +47,7 @@
memq memql memqual rmemq rmemql rmemqual countq countql countqual
posq posql posqual rposq rposql rposqual eq eql equal meq meql mequal
neq neql nequal max min clamp bracket take drop if or and progn
- prog1 prog2 nilf tf display-width sys:fmt-simple
+ prog1 prog2 nilf ignore tf display-width sys:fmt-simple
sys:fmt-flex sys:fmt-join packagep
symbolp keywordp bindable stringp length-str
coded-length cmp-str string-lt str= str< str> str<= str>= int-str
diff --git a/stdlib/doc-syms.tl b/stdlib/doc-syms.tl
index 067d3701..4046ea49 100644
--- a/stdlib/doc-syms.tl
+++ b/stdlib/doc-syms.tl
@@ -985,6 +985,7 @@
("ignbrk" "N-02391683")
("igncr" "N-02391683")
("ignerr" "N-007287AC")
+ ("ignore" "N-007E0508")
("ignpar" "N-02391683")
("ignwarn" "N-02552A58")
("imaxbel" "N-02391683")
@@ -1324,7 +1325,7 @@
("next-file" "N-00839D2F")
("nf" "N-0267AE6D")
("nil" "N-015134D8")
- ("nilf" "N-032070EB")
+ ("nilf" "N-007E0508")
("ninth" "N-01B0FA33")
("nl0" "N-03BD477F")
("nl1" "N-03BD477F")
@@ -1994,7 +1995,7 @@
("test-neq-set-indent-mode" "N-01A1F89C")
("test-set" "N-036C7E9E")
("test-set-indent-mode" "N-01A1F89C")
- ("tf" "N-032070EB")
+ ("tf" "N-007E0508")
("third" "N-01B0FA33")
("throw" "D-0053")
("throwf" "N-015466AD")
diff --git a/txr.1 b/txr.1
index 7be5a547..159c958d 100644
--- a/txr.1
+++ b/txr.1
@@ -58769,10 +58769,11 @@ with both optional arguments omitted:
[iff a] <---> [iff a identity nilf] <---> a
.brev
-.coNP Functions @ tf and @ nilf
+.coNP Functions @, tf @ nilf and @ ignore
.synb
.mets (tf << arg *)
.mets (nilf << arg *)
+.mets (ignore << arg *)
.syne
.desc
The
@@ -58789,6 +58790,11 @@ and the
function returns
.codn nil .
+The
+.code ignore
+function is a synonym of
+.codn nilf .
+
Note: the following equivalences hold between these functions and the
.code ret
operator, and
@@ -58813,6 +58819,11 @@ and
[mapcar (ret nil) list] <--> [mapcar nilf list]
.brev
+Note: the
+.code ignore
+function can be used for suppressing unused variable
+warnings.
+
.TP* Example:
.verb
@@ -58851,6 +58862,16 @@ is even, then iff passes it into the
function, which ignores the value and returns
.codn nil .
+The following example shows how
+.code ignore
+may be used to suppress compiler warnings about unused parameters
+or other variables:
+
+.verb
+ (defun (x y)
+ (ignore x y))
+.brev
+
.coNP Function @ retf
.synb
.mets (retf << value )