Knuth hid a special rule for delimited arguments in exercise 20.5 of the TeXbook.
If the very last character of the parameter text is #, so that this # is immediately followed by {, TeX will behave as if the { had been inserted at the right end of both the parameter text and the replacement text.
This means that a macro can be defined as,
\def\a#1#{#1}
calling it as \a 10
will give a runaway argument error
whereas calling it as \a{12}
, will compile with no trouble.
I struggled to find a practical application for such macros even after looking at TeX by Topic, TeXbook and LaTeX source.
Here is my take on it, create some commands to typeset and do some calculations for fractions, as for example those found in basic arithmetic texbooks. You type this,
\[\FRAC ADD{3}{8}+{1}{7}\]
\[\FRAC SUB{5}{8}-{1}{7}\]
\[\FRAC MUL{5}{8}x{13}{1201}\]
and you get this:
Here is the code,
\documentclass{article}
\begin{document}
%% macro factory
\def\FRAC#1#{\csname #1\endcsname}
%% add
\def\ADD#1#2+#3#4{%
\frac{#1}{#2}+\frac{#3}{#4}=
\frac{\the\numexpr(#4*#1)+(#3*#2)}{\the\numexpr#2*#4}
}
%% subtract
\def\SUB#1#2-#3#4{%ok top
\frac{#1}{#2}-\frac{#3}{#4}=
\frac{\the\numexpr(#4*#1)-(#3*#2)}{\the\numexpr(#2*#4)}
}
%% multiply
\def\MUL#1#2x#3#4{%
\frac{#1}{#2}\times\frac{#3}{#4}=
\frac{\the\numexpr(#1*#3)}
{\the\numexpr#2*#4}
}
%% testing
\[\FRAC ADD{3}{8}+{1}{7}\]
\[\FRAC SUB{5}{8}-{1}{7}\]
\[\FRAC MUL{5}{8}x{13}{1201}\]
\end{document}
Are there any practical applications for such macros? Are there any special precautions one should take? Why would Knuth include this facility in the first place?