You are here: Home / Przedsięwzięcia/Projects / TeX Pearls / 2006 Pearls / pawel-jackowski / bachotex2006-pawel-jackowski-pearl1.tex


TeX document icon bachotex2006-pawel-jackowski-pearl1.tex — TeX document, 1 KB (1298 bytes)

File contents

%%% Pawe\l{} Jackowski: \relax ex machina

% Guess what is the meaning of macros in the following cases:

\edef\stra{\csname undefined\endcsname}

\meaning\stra % -> \undefined (\undefined is equal to \relax)
\meaning\strb % -> (empty)
\meaning\strc % -> \relax
\meaning\strd % -> \relax

% ...and can you explain why \ifx\strc\strd is false, although both control
% sequences have the same meaning?

\ifx\strc\strd true\else false\fi \message{?\strc?\strd?}

% Since the behavior of \relax is somewhat weird, I've learned to dislike
% the \relax acting as the universal string delimiter in cases such as

\expandafter\gobbler\strc whatever \relax

  \ifx\relax#1\else\message{Can you see that #1?!}%
\expandafter \iterator \stra whatever \relax

% Instead I propose


% -- no endless loop in spite of recursion (expands to itself)
% -- alike \relax, \endstr returns nothing (a sort of...) if typeset
% -- side effect is that \endstr stops assignments (as \relax do)
% -- \ifx\endstr\relax is false, so we can distinguish them
% -- but be careful: \if\endstr\relax is true


Document Actions