home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!news.service.uci.edu!unogate!mvb.saic.com!info-tex
- From: <barr@triples.Math.McGill.CA>
- Newsgroups: comp.text.tex
- Subject: Problems with false conditionals
- Message-ID: <9301260054.AA18998@triples.math.mcgill.ca>
- Date: Mon, 25 Jan 93 19:54:11 EST
- Organization: Info-Tex<==>Comp.Text.Tex Gateway
- X-Gateway-Source-Info: Mailing List
- Lines: 60
-
-
- The following four lines cause an error:
- \iffalse
- \newif\iftest
- \fi
- \bye
-
- On the other hand, these four don't:
- \iftrue
- \newif\iftest
- \fi
- \bye
-
- I am trying to do something with conditional compilation. So I defined
- a \newif that can be set true or false to determine which of two paths
- to follow. The problem is that the false path included the use of a
- macro named \ifnnull (if non-null) that included an \if in its
- definition and in use was to be complemented by a \fi. Here is a
- simplified version of what it all looked like:
-
- \newif\ifTotOnly
- \TotOnlytrue
-
- \def\ifnnull#1{\def\next{#1}\ifx\next\empty\else}
-
- \ifTotOnly
- %%%% Next line cases trouble when \TotOnlyfalse:
- \newif\ifnnull
-
- %% stuff when \TotOnlytrue
-
- \else
-
-
- %% stuff when \TotOnlyfalse that uses \ifnnull ... \fi
-
- \fi
-
- %% rest of file
-
- Now what happened was that when \TotOnlyfalse, then the TeX skipping
- mechanism didn't recognize the pairing of \ifnnull with \fi. So I put
- in a useless \newif\ifnnull to fool the parser, but then, to my
- surprise, I discovered that when \TotOnlytrue, I got this error message:
- ! Incomplete \iffalse; all text was ignored after line 43.
- <inserted text>
- \fi
- <to be read again>
- \newif
- l.44 \newif
- \ifnnull
-
- It appears that you cannot put a \newif inside a false conditional, but
- you can inside a true one. Finally, I reduced the question to the
- minimal files above. I think the correct explanation is really the same
- thing that led me to this kludge in the first place: the parser sees
- \ifnnull as an \if, even when it is just being defined. But it does not
- see it as an \if when it is just a control sequence.
-
- Michael Barr
-