garry@lasspvax.UUCP (Garry Wiegand) (01/12/86)
A TeXnical question: ((('N' key everyone!))) \newskip\A \newdimen\B \B = 8pt \ifdim \B > 2pt \B = 2pt \fi \showthe \B % answer is '2' \B = 8pt \ifdim \B > 2pt \B = 2pt \fi \showthe \B % answer is '2' \B = 8pt \relax \ifdim \B > 2pt \B = 2pt \fi \showthe \B % answer is '2' \B = 8pt \relax \ifdim \B > 2pt \B = 2pt \fi \showthe \B % answer is '2' \A = 8pt \ifdim \A > 2pt \A = 2pt \fi \showthe \A % answer is '8'!!! \A = 8pt \ifdim \A > 2pt \A = 2pt \fi \showthe \A % answer is '2'!!! IS THIS A BUG IN TEX, OR IS IT ME?? (you never know with Tex) (This problem extracted from horrible overburden. Took a while to find, given the "every-other-time" property.) In context, the \relax no longer was ameliorative. We are using "VAX/VMS version 1.1". garry wiegand garry@lasspvax.tn.cornell.edu
bdm@ra.anu.OZ (Brendan McKay) (01/18/86)
In article <777@lasspvax.UUCP>, garry@lasspvax.UUCP (Garry Wiegand) writes: > > A TeXnical question: [ edited by bdm ] > > \newskip \A > > \A = 8pt \ifdim \A > 2pt \A = 2pt \fi \showthe \A % answer is '8'!!! > \A = 8pt \ifdim \A > 2pt \A = 2pt \fi \showthe \A % answer is '2'!!! > The explanation goes something like this: When TeX has read the first "\A = 8pt" it doesn't know the assignment has finished yet (it might continue "plus 3pt" or something). So it has to expand the \ifdim ... \fi. \A hasn't yet had it's value changed from the initial 0pt, so the \ifdim ... \fi expands to nothing. TeX now sees the \showthe, realises the <dimen> has finished, assigns "8pt plus0pt minus0pt" to \A and processes the \showthe. It DOESN'T reevaluate the \ifdim ... \fi. On the next line, the \ifdim ... \fi expands to "\A = 2pt " so TeX altogether sees "\A = 8pt \A = 2pt \showthe \A". This behaviour may be counter-intuitive, but it's not a bug. Equally weird behaviour would be possible if the rules were changed to specify re-evaluation of the \ifdim ... \fi. Consider this one under both possibilitities: \newskip \X \X = 8pt \ifdim \X > 2pt plus 1pt \fi \relax . The solution is to insert \relax after the 8pt. Brendan McKay. Computer Science Dept., Australian National University, GPO Box 4, Canberra, ACT 2601, Australia. ACSnet: bdm@anucsd.anu.oz ARPA: bdm%anucsd.anu.oz@seismo CSNET: bdm@anucsd.anu.oz@csnet-relay.csnet JANET: anucsd.anu.oz!bdm@ukc UUCP: {decvax,vax135,pesnta,eagle}!mulga!anucsd.anu.oz!bdm {seismo,ubc-vision,ukc,mcvax,prlb2}!munnari!anucsd.anu.oz!bdm [ UUCP routes through munnari prefered ]
garry@lasspvax.UUCP (Garry Wiegand) (01/22/86)
In a recent article bdm@ra.anu.OZ (Brendan McKay) wrote (in reply to me):
> The explanation goes something like this...
Brendan, your reply is clear and succinct, and I thank you for it.
Now I just wish TeX had the same properties! :-)
garry wiegand
garry%geology@lasspvax.tn.cornell.edu