When playing with recursive functions of expl3 it has happened several times to me that a quark got expanded unintentionally, in which case TeX will go into an infinite expansion loop. (What is extra annoying is that my console doesn't react to Ctrl+C in that case, so that I have to kill the process manually.)
So I'm wondering if quarks have to be defined in that self-expanding manner at all. There seem to be two use cases for them:
As delimiters of various functions with delimited parameters, e.g.
\q_recursion_stop. In that case the definition of the quark doesn't even matter, because TeX's expansion mechanism only scans for a token with that name, no matter if it is defined or not.When comparing if a token is equal to a quark, e.g.
\quark_if_recursion_tail_stop:Nhas a test\if_meaning:w \q_recursion_tail #1 ... \fi:\if_meaning:wis the same as\ifx, so it doesn't really expand the macros here but does an internal comparison of each token in the replacement text. That means we don't need a recursive macro in this case either. A definition like\cs_new:Nn \quark {\quark_undefined}would be fine as well, while at the same time preventing accidental infinite loops.
Are there situations in which it's absolutely necessary to have a recursive quark definition?
\quarkwas meant to be a general pattern for a quark name, so that the definition also includes a new command each time. As the number of quarks in a program should be very low, this wouldn't be a problem. – siracusa May 31 '19 at 17:44