I'm reading TeX by Topic, but in little chunks (rather than from first page to last) and just read the stuff on conditionals. I want to be sure that I understand what's going on when TeX starts skipping stuff. What I've gleaned so far is that in, say, \iffalse ... \fi then:
TeX doesn't do expansions.
TeX keeps track of
\if...s to ensure that the\fireally matches the\iffalse.
It's that last bit that I'm wanting to make sure that I get straight in my head. To make it a precise question:
What exactly is an \if...?
One reason for my worry is that I have some pseudo-ifs in my code, where a command starts \if... but isn't actually an \if. On the other hand, what if I had a command that didn't start with the three characters \if but happened to be \let to an \if? So, for example, which of the following count as an \if when the macro (not the definition of it) is used between \iffalse ... \fi:
\let\ifabc=\ifx(so, to be clear, what happens in\iffalse ... \ifabc ... \fi, does the\ifabccount as an\if?\def\ifabc{\ifx}\edef\ifabc{\ifx}\let\ifabc=\SomePreviouslyDefinedCommandThatIsntAnIf\let\abc=\ifx
\ifx? (And presumably the test isn't against the actual, say,\if, but against an immutable\if. So if I did\let\if=\somethingelsethen it wouldn't break the matching mechanism.) – Andrew Stacey Feb 25 '11 at 09:32\newifinside\if…\fibreaks is, as far as I can tell, that\newifis outer, so it is not allowed in skipped text. – Harald Hanche-Olsen Feb 25 '11 at 09:39\ifx, but I think it is executed deeper in TeX. And yes, AFAIK TeX is keep the original definitions of the primitives around even when they are redefined to macros. – Martin Scharrer Feb 25 '11 at 09:40\newifisn't\outerin LaTeX but in TeX, don't ask me why. What I meant with this line was that defining and using a new\if...inside a conditional path which can be false will break, because it will then not be defined and not match its\fis. – Martin Scharrer Feb 25 '11 at 09:45\let\somethingelse\if \let\if\relax \show\somethingelsefor example: It says\somethingelsemeans\ifeven though\ifdoesn't mean\ifanymore. The tests done when skipping text is against the TeX primitives – the names of commands is irrelevant. Uh, maybe that means the answer to your question is “yes”. – Harald Hanche-Olsen Feb 25 '11 at 09:47\let\mymacro\relax \def\relax{} \show\mymacrogives\mymacro=\relax., so TeX still remembers the original primitive\relax. That was what I meant. – Martin Scharrer Feb 25 '11 at 09:47\letworks. And if you leave away\let\mymacro\relaxbefore\def\relax{}, then\relaxis gone. (OK,\relaxis easily reconstructed, but with\ifyou're lost then, I think.) – Hendrik Vogt Feb 25 '11 at 10:04\show = \show, etc.), the second '\show' is an internal token and not a 'normal' control sequence. That's why something like\let\mymacro\relax \def\relax{} \show\mymacrogives\mymacro=\relax: you are seeing the internal token (essentially the memory location containing the definition of, in this case, the\relaxprimitive). – Joseph Wright Feb 25 '11 at 10:10\(pdf)primitiveto get at the original definition. – Joseph Wright Feb 25 '11 at 10:33\def\primitive{}?:-)– Hendrik Vogt Feb 25 '11 at 10:45\outerfor\newifas it is a pain as you can't do lots of 'natural' things. (Indeed, for LaTeX3 we're not using\outerat all.) – Joseph Wright Feb 25 '11 at 10:50\ifprimitive" we mean a control sequence token whose meaning is the original (IniTeX) meaning of\if. TeX usually tests not for a specific control sequence, but for specific meanings. (An important exception is\par.) As a corollary to Martin's explanations, you cannot easily define a macro that can be used with the same syntax as the conditional primitives (a popular way is\let\then\iffalse \def\ifsomething\then{}). – Philipp Feb 25 '11 at 17:05