Article View: comp.text.tex
Article #1966Re: reserving registers from within macros
From: Navindra S Gambhir
Date: Wed, 02 Sep 1992 04:05
Date: Wed, 02 Sep 1992 04:05
49 lines
2665 bytes
2665 bytes
In article <repasky.715398745@sun.bdc.ubc.ca> repasky@bdc.ubc.ca (Dick Repasky) writes:
> 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?
>
The problem arises because all the \new... macros (\newcount, \newdimen,
..., \newinsert, etc.) are defined as \outer in plain TeX, and so are
``not allowed to appear in any place where tokens are being absorbed at
high speed.'' An \outer macro cannot appear in the replacement text of
a definition, among other places (The TeXbook, p.206).
I do not know why this decision (i.e., to have all allocations to be
global) was made; it sure is a nuisance to have to first name all the
``variables'' (i.e., give a name to the registers) that you will ever
need, instead of have them ``declared'' when you actually need them.
(And since all allocations are \global, you also cannot get away with
temporary ``declarations'' inside \begingroup and \endgroup.)
> Note that this proceedure works wonderfully if I change it to generate macro
> definitions on macros that have different names. The problem arises
> when any \new"register" sequence is to be defined.
>
Figures, because \def is different from \new<whatever>.
> My goal is to be able to allocate multiple insert lists and operate on them
> from a common macro.
>
Short of redefining \new... to the exact same thing, but without the
\outer, I do not see any way out. But this in not very desirable,
since ``the inside story of how allocation is actually performed should
not be relevant when the allocation macros are used at a higher level;
you mustn't assume that plain.tex really does allocation in any
particular way'' (The TeXbook, p.346).
Maybe the Wizards will soon followup.
--
---------------------------------------------------------------------------
Navindra S Gambhir gambhir@cs.cornell.edu
I would rather write programs to help me write programs than write programs
Technical Details
Message-ID:
<1992Sep2.040517.18955@cs.cornell.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!gambhirReferences:
<repasky.715398745@sun.bdc.ubc.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!gambhir From: gambhir@cs.cornell.edu (Navindra S Gambhir) Newsgroups: comp.text.tex Subject: Re: reserving registers from within macros Keywords: \new..., register, reserve, macro, definition, forbidden control seq. Message-ID: <1992Sep2.040517.18955@cs.cornell.edu> Date: 2 Sep 92 04:05:17 GMT References: <repasky.715398745@sun.bdc.ubc.ca> Organization: Cornell University, Ithaca NY 14853 Lines: 49