9

Is LuaTeX beta-0.79.1 correct in thinking the following is valid input:

\iftrue
\bye
0

1 Answer 1

12

An \outer macro is illegal only in a skipped branch of a conditional (and in arguments to macros, but it's not relevant here).

What happens when TeX processes a conditional in the form

<if><test><true text>\else<false text>\fi

where <if> stands for a primitive conditional and <test> is the list of tokens required by it for deciding about following the true branch or the false branch is:

  • the test turns out true: remove <if><test> from the input stream

  • the test turns out false: remove <if><test> and all tokens up to and including the matching \else (keeping track of conditionals in <true text>)

In both cases the conditional level is increased by one, to be decreased when \else or \fi will be expanded.

In your case you have

\iftrue\bye

that removes \iftrue and increases the conditional level; the <test> is empty for \iftrue. Then \bye is expanded and it causes the job to end. Since the conditional level is greater than 0 at this moment, a warning

(\end occurred when \iftrue was incomplete)

is issued.

This is standard behavior in original TeX: it doesn't go “all the way” to the matching \fi. An \else remaining in the case the conditional is true will skip the tokens up to and including the matching \fi and decrease the level. If no \else is found, the expansion of \fi decreases the level, leaving nothing in the input stream.

An \outer macro in a skipped branch will cause an error of “Incomplete conditional”, because TeX assumes something wrong happened. But non skipped tokens are expanded or executed normally.

2
  • An \outer macro is incorrect when it is scanned to the parameter too. Commented Oct 14, 2014 at 20:17
  • @wipet Yes, of course, but there's no macro with arguments here. I guessed that Angel thought an outer macro illegal also in that context. However I added a note about this, thanks for noting. Commented Oct 14, 2014 at 20:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.