engine: \global in front of a LaTeX length command - #98
Merged
Conversation
\global\setlength\xx{5pt} inside a group was a LOCAL assignment: it took effect
inside the group and was undone on the way out, in silence. \global\xx=5pt and
\global\advance\xx by4pt both worked, which is what kept the hole out of sight.
In TeX a prefix applies to the assignment it finds after EXPANDING what follows —
tex.web §1211 takes "the next non-blank non-relax NON-CALL token", so a macro is
expanded away. \setlength is a macro there (ltlength.dtx: \def\setlength#1#2{#1
#2\relax}), so \global reaches the register assignment by itself. Here it is a
primitive, which getXToken does not expand, and doGlobal's switch had no case for
it: the default branch put the token back and ran it locally.
The machinery was already in place — assignLength takes a global flag that nothing
ever passed as true. \setlength, \addtolength, \settowidth, \settoheight and
\settodepth now receive the prefix, so they reach both a \newlength register and
one of the engine's dimension parameters (\textwidth is \let to \hsize, a
different path, same rule).
Measured over 200 real beamer talks: 0 documents lost, 0 outputs changed, page
count identical — the change is inert on that corpus, which is what a fix this
narrow should look like.
One test case of mine was wrong before the engine was: I asserted \the\xx after
setting \textwidth. Removed; the parameter path has its own test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
\global\setlength\xx{5pt}inside a group was a local assignment: it tookeffect inside the group and was undone on the way out, in silence.
\global\xx=5ptand\global\advance\xx by4ptboth worked, which is what keptthe hole out of sight.
Why TeX does not have it
tex.web§1211: a prefix applies to the assignment it finds after expandingwhat follows — it takes "the next non-blank non-relax non-call token", so a
macro is expanded away. And
\setlengthis a macro there:so
\globalreaches the register assignment by itself. Here\setlengthis aprimitive, which
getXTokendoes not expand, anddoGlobal's switch had no casefor it — the
defaultbranch put the token back and ran it locally.The machinery was already in place:
assignLengthtakes aglobalflag thatnothing ever passed as
true.\setlength,\addtolength,\settowidth,\settoheightand\settodepthnow receive the prefix, so it works for a\newlengthregister and for one of the engine's dimension parameters(
\textwidthis\letto\hsize— a different path, same rule).Measured
Both corpora are inert, which is what a fix this narrow should look like: no
document in either set exercises
\global\setlengthin a way that reaches thepage. The behaviour is pinned by tests instead.
Both baselines were re-run with the current
mainbinary rather than reused fromearlier today —
mainmoved in between (#95 changed glyph widths by ~1.7%), and astale baseline would have credited this change with someone else's deltas.
A correction
One test case of mine was wrong before the engine was: I asserted
\the\xxaftersetting
\textwidth. Removed — the parameter path has its own test.