[tex-live] Bug?: pdflatex hangs with self-referential \newcommand{\bad}{\bad} definition
Zdenek Wagner
zdenek.wagner at gmail.com
Wed Jan 9 21:50:08 CET 2019
Hi,
such checks are generally impossible.
Example 1
\newcommand{\bad}{\newcommand{\bad}{Not so bad }\bad}\bad\bad\bad
This should work
Example 2
\newcommand{\good}{\bad}
\newcommand{\bad}{\good}
\bad
This hangs due to tail expansion
Zdeněk Wagner
http://ttsm.icpf.cas.cz/team/wagner.shtml
http://icebearsoft.euweb.cz
st 9. 1. 2019 v 18:26 odesílatel Jess Riedel <jessriedel at gmail.com> napsal:
>
> The point about pdftex not being able to solve the halting problem is well taken. I guess the only counterargument is that some easy checks could be made, like compilers that warn the user that if(x=1) probably should be if(x==1). But there are always speed and maintenance costs to having a bunch of checks, and I trust y'all's judgement.
>
> Thanks very much for the thorough answer.
>
> On Wed, Jan 9, 2019, 11:21 AM Zdenek Wagner <zdenek.wagner at gmail.com wrote:
>>
>> The problem with \newcommand{\bad}{\bad} is that it is a tail
>> expansion, this means that it does not eat stack, it just loops
>> forever. \newcommand{\bad}{\bad x} will probably report stack
>> overflow. It is documented in The TeXbook.
>>
>> Zdeněk Wagner
>> http://ttsm.icpf.cas.cz/team/wagner.shtml
>> http://icebearsoft.euweb.cz
>>
>> st 9. 1. 2019 v 17:09 odesílatel Philip Taylor <P.Taylor at rhul.ac.uk> napsal:
>> >
>> > David Carlisle wrote:
>> > > This plain tex document also loops
>> > >
>> > > \let\par\relax x\vfill
>> >
>> > This one is more fun:
>> >
>> > \tracingall \let \par = \relax x \vfill
>> >
>> > ** Phil.
>> >
More information about the tex-live
mailing list