LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Frank Mittelbach <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Fri, 7 Mar 2008 21:29:07 +0100
text/plain (81 lines)
David Kastrup writes:
 > Ok, I get bombed out with save stack size exceeded in a large document.
 > At the end of the document.  Here is an example (bombs out with a save
 > stack size of 5000, adjust the number for other binaries):
 > \documentclass{minimal}
 > \begin{document}
 > \leavevmode
 > \newcount\xxx
 > \loop
 > \label{xxx\number\xxx}
 > \advance\xxx1
 > \ifnum\xxx<10000
 > \repeat
 > \end{document}
 > Bombs out only when run with an empty .aux file.  What is the problem?
 > At the end of the document,
 > \@ifdefined{something}
 > is run within a local group for all labels.  This replaced the undefined
 > label _locally_ with \relax and pushes the outer "undefined" value onto
 > the save stack.

nice one. that goes back to 2.09 or earlier.

 > This is idiotic.  

well more an oversight I woudl say. Leslie clearly has been aware of the save
stack problem as such which is one of the reasons why the document environment
explicitly cancels its environment group

 > Of course, by far the easiest solution is
 > \ifx\ifcsname\@undefined
 >   make a definition that first checks with \ifcsname, and only if that
 >   does not yield undefined, checks against \relax
 > \else
 >   the old definition
 > \fi
 > This is incompatible in that it does not have the sideeffect of turning
 > an undefined macro locally into \relax.
 > This is the solution I prefer.  It will avoid save stack buildup (and
 > sideeffects I don't consider useful) elsewhere, too.

on the 2e level I wouldn't be surprised if the side effect is actually in use
in places.

 > Another possibilities are to remove the grouping from the end of
 > document action testing the labels. 

from briefly staring at the code I see no reason why this group is needed at
all. Does anybody see one why it could make a difference?

 >  Yet another is to perform the
 > \@ifdefined test within a group of its own, namely as
 > \begingroup \@ifdefined{xxx}{\endgroup...}{\endgroup...}
 > This will also not have the side effect of changing the label internal
 > to \relax and will avoid save stack buildup.  So it keeps the changed
 > side effect to a very small area and does not depend on eTeX.  One could
 > also implement both (which would help with non-eTeX as well), but I
 > don't think that supporting large documents on non-eTeX that previously
 > did not work is much of a priority.
 > What is your take?  I find it clearly unsatisfactory to have LaTeX eat
 > up save stack for newly defined labels like that at the end of the
 > document.

well, you seem to be the first person getting into trouble with this, but that
doesn't mean one shouldn't fix it.

I don't really mind either of the three solutions (provided none of the kills
the regression tests for 2e) but personally I would simply drop the group
unless somebody can give me a good reason why it could be needed in a certain