It depends on the definition
After
\def\do{hello}
then \do
will expand to hello
....
In the core latex format it has two unrelated uses.
It is used in "executable lists" in a style derived from plain TeX and described in the TeXBook.
For example verbatim
internally uses a list defined via
\def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&%
\do\#\do\^\do\_\do\%\do\~}
If \dospecials
list had been defined as
\def\dospecials{,\ ,\\,\{,\},\$,\&%
,\#,\^,\_,\%,\~}
or
\def\dospecials{\ \\\{\}\$\&%
\#\^\_\%\~}
you would need some loop macro to iterate over the list but by having a command separator, all you need to do is define \do
locally and then execute the list so `verbatim does
\let\do\@makeother
\dospecials
and \@makeother
is applied to each of the tokens.
The other use is as a delimited argument. If you had needed a looping macro you could have used the form
\@tfor\tmp:=\dospecials\do{\expandafter\@makeother\tmp}
for the form with no commas, or
\@for\tmp:=\dospecials\do{\expandafter\@makeother\tmp}
for the form with commas.
here :=
and \do
are not actually defined to do anything they are just tokens used to delimit the arguments of \@for
which is defined via
\long\def\@for#1:=#2\do#3{%
....
so the list variable (#1
) is everything up to :=
and the list (#2
) is (after expansion) everything between :=
and \do
, with the list body (#3
) being the next token or brace group after \do
.
texdoc texbytopic
) on p.123. the code referred to comes direct fromplain.tex
, and there may be more explanation in appendix b of the texbook (but i haven't looked).