🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #2016

Re: reserving registers from within macros

#2016
From: David Carlisle
Date: Wed, 02 Sep 1992 09:07
76 lines
3861 bytes
>>>>> On 2 Sep 92 04:05:17 GMT, gambhir@cs.cornell.edu (Navindra S Gambhir) said:

> I've made the following attempt:
> 
>     \def\doit#1{\expandafter\newinsert\csname big#1\endcsname}
> 
> and I receive the error that \newinsert is a forbidden command sequence in
> a macro definition.  Does anyone have advice?
> 

Navindra> The problem arises because all the \new... macros (\newcount, \newdimen,
Navindra> ..., \newinsert, etc.) are defined as \outer in plain TeX, 
........
Navindra>An \outer macro cannot appear in the replacement text of
Navindra> a definition, among other places (The TeXbook, p.206).
......
Navindra> Short of redefining \new... to the exact same thing, but without the
Navindra> \outer, I do not see any way out.  But this in not very desirable,
Navindra> since ``the inside story of how allocation is actually performed should
Navindra> not be relevant when the allocation macros are used at a higher level;
Navindra> you mustn't assume that plain.tex really does allocation in any
Navindra> particular way'' (The TeXbook, p.346).

Arghhhh! Down with \outer'ness!

It may not be `desirable' but in LaTeX, Lamport does exactly what you
suggest, he repeats the definitions of (most of) the allocation macros
without the \outer.

A trick I use sometimes to include \outer macros is to use \csname
\endcsname as in:

\def\doit#1{%
 \csname newinsert\expandafter\endcsname\csname big#1\endcsname}

Note that there is a price to pay here, \newinsert is one token, but
\csname newinsert\endcsname is 11.

So if you are doing a lot of this, I would redefine all the \outer
commands in plain tex, just repeat the definition without the \outer,
there are not too many, I find:

Lines matching "\\\\outer" in buffer plain.tex.
 15:\catcode`\^^L=\active \outer\def^^L{\par} % ascii form-feed is "\outer\par"
220:\outer\def\newcount{\alloc@0\count\countdef\insc@unt}
221:\outer\def\newdimen{\alloc@1\dimen\dimendef\insc@unt}
222:\outer\def\newskip{\alloc@2\skip\skipdef\insc@unt}
223:\outer\def\newmuskip{\alloc@3\muskip\muskipdef\@cclvi}
224:\outer\def\newbox{\alloc@4\box\chardef\insc@unt}
226:\outer\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}}
227:\outer\def\newtoks{\alloc@5\toks\toksdef\@cclvi}
228:\outer\def\newread{\alloc@6\read\chardef\sixt@@n}
229:\outer\def\newwrite{\alloc@7\write\chardef\sixt@@n}
230:\outer\def\newfam{\alloc@8\fam\chardef\sixt@@n}
231:\outer\def\newlanguage{\alloc@9\language\chardef\@cclvi}
237:\outer\def\newinsert#1{\global\advance\insc@unt by\m@ne
259:\outer\def\newif#1{\count@\escapechar \escapechar\m@ne
603:\def\tabalign{\us@true\m@ketabbox} % non-\outer version of \+
604:\outer\def\+{\tabalign}
636:\outer\def\beginsection#1\par{\vskip\z@ plus.3\vsize\penalty-250
639:\outer\def\proclaim #1. #2\par{\medbreak
714:\outer\def\bye{\par\vfill\supereject\end}


David

--
                           David Carlisle
                                    JANET: carlisle@uk.ac.man.cs

                                    Computer Science Department
                                    Manchester University
                                    Oxford Road
                                    Manchester
                                    England
                                    M13 9PL
Technical Details
Message-ID: <CARLISLE.92Sep2100731@r8d.cs.man.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!mucs!m1!carlisle
References: <repasky.715398745@sun.bdc.ubc.ca> <1992Sep2.040517.18955@cs.cornell.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!mucs!m1!carlisle
From: carlisle@cs.man.ac.uk (David Carlisle)
Newsgroups: comp.text.tex
Subject: Re: reserving registers from within macros
Message-ID: <CARLISLE.92Sep2100731@r8d.cs.man.ac.uk>
Date: 2 Sep 92 09:07:31 GMT
References: <repasky.715398745@sun.bdc.ubc.ca> <1992Sep2.040517.18955@cs.cornell.edu>
Sender: news@cs.man.ac.uk
Organization: Department of Computer Science, University of Manchester
Lines: 76
In-reply-to: gambhir@cs.cornell.edu's message of 2 Sep 92 04:05:17 GMT