Here is a minimal non-working example:
\documentclass{article} \begin{document} \let\@var\@empty \newcommand{\append}[1]{ \xdef\@var{\@var #1} } \append{1} \append{2} \append{3} \@var \end{document} I was expecting \@var to contain the string 1 2 3, but instead I get the following error:
! TeX capacity exceeded, sorry [input stack size=5000]. \@var->\@var How can I achieve what I was expecting to achieve?