[comp.text.tex] a pictex problem

kuplinsk@math.rutgers.edu (Julio Kuplinsky) (03/21/90)

Can anyone figure out what's wrong with the following code? I get
the error message

! Incomplete \iffalse; all text was ignored after line 6.
<inserted text> 
                \fi 
<to be read again> 
                   \newbox 

********************************************************************

\input pictex
\newif\ifpicmode
\picmodefalse


\ifpicmode 
\beginpicture
\newbox\pica %
  \setbox\pica=\hbox{%
   \beginpicture
    \put {a} at 0 0 
   \endpicture}
\put {\box\pica} at 0 0 
\endpicture
\fi
\bye

*************************************************************************

Thanks.
Julio Kuplinsky

emcmanus@cs.tcd.ie (Eamonn McManus) (03/22/90)

kuplinsk@math.rutgers.edu (Julio Kuplinsky) writes:
...
>! Incomplete \iffalse; all text was ignored after line 6.
><inserted text> 
>                \fi 
...
>\ifpicmode 
>\beginpicture
>\newbox\pica %
...

Oh vomit, it's \outer control sequences again.  TeX has this idea that
certain commands are not allowed to be skipped over, for example in the
text ignored because of a false conditional.  This is meant to prevent your
document getting completely absorbed if you forget to put in a \fi for a
false conditional, and in similar circumstances.  Unfortunately, because of
cases like this it's more trouble than it's worth.

The particular sequence in question is \newbox.  There are two ways to work
around the problem; either replace \newbox by \csname newbox\endcsname, or
stop \newbox from being \outer.  I'm including the text of an article I
sent to TeXHaX some time back explaining how to do the latter.

To: TeXhax Digest <TeXhax@cs.washington.edu>
Subject: \outer considered painful
Lines: 58
Date: Tue, 10 Jan 89 17:13:29 +0000
From: Eamonn McManus <emcmanus@cs.tcd.ie>

Am I alone in thinking that \outer macros are a mistake in the design of
TeX?  There are no macros marked so in plain.tex that I couldn't imagine
wanting to use in the definition of another macro.  About the only thing
I can think of that should be \outer is the end of file, or maybe ^^L as
well.  I can't see why I should not be able to define a macro that makes
use of \newcount, or use \beginsection or \proclaim in conditional text.
The additional diagnostic information provided by \outerness cannot make
up for its painfulness to macro writers (OK, so I'm a macro writer).

I'm inclined to think Leslie Lamport would agree with me, given that the
LaTeX package doesn't define any new \outer macros, and it must redefine
some existing ones so it can use them in other macros.  A \nonouter that
could be placed before \outer macros to cancel their \outerness just for
that occurrence would be enough to make me happy.  Failing that, here is
a TeX source that redefines all of Plain's \outer macros not to be.  Any
better technique that accomplishes this for macros with parameters would 
interest me greatly.

--
Eamonn McManus				emcmanus@cs.tcd.ie
Distributed Systems Group, TCD		...!uunet!mcvax!cs.tcd.ie!emcmanus

% unouter.tex - remove the concept of \outer from plain TeX
% By Eamonn McManus Nov 88.  This file is not copyrighted.

% This macro removes the outerness of the control sequence \csname#1\endcsname
% by copying it to \csname un*#1\endcsname and then defining
% \csname#1\endcsname to be a macro that expands to that.  For example,
% after \unouter{proclaim}, we have: \proclaim=macro:->\un*proclaim .
% and \un*proclaim=\outer macro:->[original definition of \proclaim] .
% It would be nice if we could avoid this extra level, but I know of no way
% of doing that short of writing the \meaning to a file and reading that in
% again (yeuch).
\def\unouter#1{\toks0=\expandafter{\csname un*#1\endcsname}%
	\edef\next{\let\the\toks0=}\expandafter\next\csname#1\endcsname
	\expandafter\edef\csname#1\endcsname{\the\toks0}}

% In the case where the macro has no parameter text, we can unouter it
% directly by putting its expansion into a token list and redefining it
% in terms of that expansion.
\def\simpunouter#1{%
	\toks0=\expandafter\expandafter\expandafter{\csname#1\endcsname}%
	\expandafter\edef\csname#1\endcsname{\the\toks0}}

% ^^L is defined as \outer\par
\let^^L=\par

% Change everything else defined as \outer.
\simpunouter{newcount} \simpunouter{newdimen} \simpunouter{newskip}
\simpunouter{newmuskip} \simpunouter{newbox} \simpunouter{newtoks}
\simpunouter{newread} \simpunouter{newwrite} \simpunouter{newfam}
\simpunouter{+} \simpunouter{bye}
\unouter{newhelp} \unouter{newif} \unouter{beginsection} \unouter{proclaim}

% \unouter no longer needed, and remove the offending primitive!
\let\unouter=\undefined \let\simpunouter=\undefined \let\outer=\relax

\endinput
--
Eamonn McManus <emcmanus@cs.tcd.ie>	<emcmanus%cs.tcd.ie@cunyvm.cuny.edu>
	  One of the 0% of Americans who are not Americans.