home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / text / tex / 15442 < prev    next >
Encoding:
Internet Message Format  |  1993-01-26  |  2.0 KB

  1. Path: sparky!uunet!usc!news.service.uci.edu!unogate!mvb.saic.com!info-tex
  2. From: <barr@triples.Math.McGill.CA>
  3. Newsgroups: comp.text.tex
  4. Subject: Problems with false conditionals
  5. Message-ID: <9301260054.AA18998@triples.math.mcgill.ca>
  6. Date: Mon, 25 Jan 93 19:54:11 EST
  7. Organization: Info-Tex<==>Comp.Text.Tex Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 60
  10.  
  11.  
  12. The following four lines cause an error:
  13. \iffalse
  14. \newif\iftest
  15. \fi
  16. \bye
  17.  
  18. On the other hand, these four don't:
  19. \iftrue
  20. \newif\iftest
  21. \fi
  22. \bye
  23.  
  24. I am trying to do something with conditional compilation.  So I defined
  25. a \newif that can be set true or false to determine which of two paths
  26. to follow.  The problem is that the false path included the use of a
  27. macro named \ifnnull (if non-null) that included an \if in its
  28. definition and in use was to be complemented by a \fi.  Here is a
  29. simplified version of what it all looked like:
  30.  
  31. \newif\ifTotOnly
  32. \TotOnlytrue
  33.  
  34. \def\ifnnull#1{\def\next{#1}\ifx\next\empty\else}
  35.  
  36. \ifTotOnly
  37. %%%% Next line cases trouble when \TotOnlyfalse:
  38. \newif\ifnnull
  39.  
  40. %% stuff when \TotOnlytrue
  41.  
  42. \else
  43.  
  44.  
  45. %% stuff when \TotOnlyfalse that uses \ifnnull ... \fi
  46.  
  47. \fi
  48.  
  49. %% rest of file
  50.  
  51. Now what happened was that when \TotOnlyfalse, then the TeX skipping
  52. mechanism didn't recognize the pairing of \ifnnull with \fi.  So I put
  53. in a useless \newif\ifnnull to fool the parser, but then, to my
  54. surprise, I discovered that when \TotOnlytrue, I got this error message:
  55. ! Incomplete \iffalse; all text was ignored after line 43.
  56. <inserted text>
  57.                 \fi
  58. <to be read again>
  59.                    \newif
  60. l.44 \newif
  61.            \ifnnull
  62.  
  63. It appears that you cannot put a \newif inside a false conditional, but
  64. you can inside a true one.  Finally, I reduced the question to the
  65. minimal files above.  I think the correct explanation is really the same
  66. thing that led me to this kludge in the first place: the parser sees
  67. \ifnnull as an \if, even when it is just being defined.  But it does not
  68. see it as an \if when it is just a control sequence.
  69.  
  70. Michael Barr
  71.