[comp.text.tex] inconsistency between TeX 2.9 and 3.0

eao@shape.mps.ohio-state.edu (Ed Overman) (09/27/90)

We just installed TeX 3.0 here over the weekend and there seems to be
an inconsistency between the new and old versions.  I get different
results with the following:

\let\PAR=\par
\if\PAR\par (TRUE) \else (FALSE) \fi
\ifx\PAR\par (TRUE) \else (FALSE) \fi
\if\PAR\$ (TRUE) \else (FALSE) \fi
\ifx\PAR\$ (TRUE) \else (FALSE) \fi
\if\PAR\# (TRUE) \else (FALSE) \fi
\ifx\PAR\# (TRUE) \else (FALSE) \fi
\bye

TeX 3.0 prints out:
(TRUE) (TRUE)
(TRUE) (FALSE)
(TRUE) (FALSE)

TeX 2.9 (on my Atari since our sysop took the old version off our Suns already)
prints out:
(TRUE) (TRUE)
(FALSE) (FALSE)
(FALSE) (FALSE)

These cannot both be correct - can they?  Can anyone tell me which is correct
(I assume the old version but I am not sure I completely understand the
description of \if in Chapter 20).  If this is a bug has anyone else seen it?

                                   Thanks, Ed Overman

piet@cs.ruu.nl (Piet van Oostrum) (09/27/90)

>>>>> In article <1990Sep27.010730.1819@zaphod.mps.ohio-state.edu>, eao@shape.mps.ohio-state.edu (Ed Overman) (EO) writes:

EO> We just installed TeX 3.0 here over the weekend and there seems to be
EO> an inconsistency between the new and old versions.  I get different
EO> results with the following:

[ Example replaced by the following simpler:]

\if\par\% TRUE\else FALSE\fi

The TeX3.0 behaviour is the correct one. Both \par and \% are not
expandable (they are not macros or anything mentioned on page 213/214)

So they are considered to have character codes 256 and thus to test equal.

Tex 2.9 and previous versions had a bug whereby \par was considered to have
character code 0 (and category code 13).
So the following example erroneously came out with TRUE:

\catcode`\%=13
\ifcat\par\noexpand%TRUE\else FALSE\fi


The fix is described in errorlog.tex:
------------------------------------------------------------------------
* 3 Dec 1989
...
S893. Distinguish |\par| from characters on |\if| tests. (MVL). @334
------------------------------------------------------------------------
(that's a strange way of saying it!)
-- 
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31 30 531806   Uucp:   uunet!mcsun!ruuinf!piet
Telefax:   +31 30 513791   Internet:  piet@cs.ruu.nl   (*`Pete')

levy@carrot.princeton.edu (Silvio Levy) (09/27/90)

eao@shape.mps.ohio-state.edu (Ed Overman) writes:

>We just installed TeX 3.0 here over the weekend and there seems to be
>an inconsistency between the new and old versions.

I've experimented a bit more and I'm convinced that 3.0 does the right
thing, at least according to my interpretation of the definition of
\if on page 209.  As I understand it \par and any \chardef control sequence
are unexpandable, so after \if they're both considered to have
"character code" 256.  More generally, all of the conditions below
should give true (and do, in 3.0):

\if\par\times \message{TRUE}\else \message{FALSE}\fi
\if\times\vskip \message{TRUE}\else \message{FALSE}\fi
\if\vskip\# \message{TRUE}\else \message{FALSE}\fi
\if\#\pageno \message{TRUE}\else \message{FALSE}\fi
\if\pageno\par \message{TRUE}\else \message{FALSE}\fi

While in 2.9 the first and last give false, thus drawing an
unjustified distinction between \par on one hand and
\times (a \mathchardef), \vskip (a primitive), \# (a \chardef)
and \pageno (a \countdef) on the other.

Silvio Levy