While reading "TeX for the impatient" on the topics of iftrue and iffalse, I encountered this example,
\def\isbigger{\let\bigger=\iftrue}
\def\isnotbigger{\let\bigger=\iffalse}
\def\test#1#2{\ifnum #1>#2 \isbigger \else \isnotbigger \fi}
\test{3}{6} \bigger$3>6$\else$3\le6$\fi \par
thinking I can do better than that, as shown below
\def\true#1#2{$#1>#2$}
\def\false#1#2{$#1\le#2$}
\def\test#1#2{\ifnum #1>#2 \true#1#2 \else \false#1#2 \fi}
\test{3}{6} \par
\test{6}{3} \par.
But wait, the book example, I wonder, may have an unsound signal(s) burried in it which I did not notice. So I explored and located this (What is iffalse for What is \iffalse for?), addressed in to find a direction leading to newif command, thus continuing my try of what follows
\newif\ifbigger
\def\test#1#2{\ifnum #1>#2 \biggertrue \else \biggerfalse \fi
\ifbigger$3>6$\else$3\le6$\fi}
\test{3}{6} \par
\test{6}{3} \par.
Satisfied with the exercies tried, I still have some concerns. Is this the burried signal I am looking for? Are there other directions that the shown programming techniques in the book are useful/crucial?
\newif\ifbigger
,\biggertrue
and\biggerfalse
are just\let\ifbigger=\iftrue
and\let\ifbigger=\iffalse
, so the third code is exactly the same as the first one.\iftrue
and\iffalse
can sometimes get handy, but in general the\newif
abstraction is better.