While was looking at the source code for pgffor, I noticed the macro \pgffor@stop is defined as
\def\pgffor@stop{\pgffor@stop}
I think the macro is used to stop argument parsing. If that's the case, what is the benefit of defining it recursively? Won't that cause an infinite loop if it is ever (accidentally) expanded? Why isn't it defined as {} or maybe even \relax?
\pgffor@stopis only used to detect something which usually will also gobble it up and not actually expand it. You can also use a macro that is never defined but that also\ifx-equals against other undefined macros (whch shouldn't be around but could be). In addition to what Joseph wrote, it also is almost impossible for a user to accidently trigger it. – Qrrbrbirlbel Oct 28 '22 at 12:22\def\pgffor@stop{}this will break very easily:\foreach \x in {1,2,,4}{``\x'' }. – Qrrbrbirlbel Oct 28 '22 at 12:28\def\foo#1\bar{#1}will pull text until it reaches\barso you want to make sure\baris never actually used inside #1. If\baris a quartk, it can't be used as text without crashing, only as a delimiter. – John Kormylo Oct 28 '22 at 14:33