Path: utzoo!attcan!uunet!van-bc!ubc-cs!fornax!laughlin From: laughlin@fornax.UUCP (Bob Laughlin) Newsgroups: comp.text.tex Subject: variables in \def Keywords: tex macros Message-ID: <2206@fornax.UUCP> Date: 28 Feb 91 02:16:46 GMT Organization: School of Computing Science, Simon Fraser University Lines: 22 After years of using LaTeX pretty much as is, I'm starting to write my own TeX macros. I'd like to know the best way to allocate and use dimen and count registers in a macro. I know I can reserve these with \newdimen\mydimen etc. or use certain ones as scratch registers, e.g. \dimen0 - \dimen9. The problem is \newdimen is outer and can't be used in a \def and so if I'm not mistaken \mydimen has to be global to the whole macro set. In a large macro package you could have an unwieldy set of global dimen names. In addition, since \dimen0 etc. are scratch registers if you call other macros in your macro there is no guarantee that they will not also use these registers and presumably destroy the contents. At least thats what I think the TeXbook says. Is there a mechanism for generating the equivalent of automatic local variable in C for TeX macros? Something whose name is hidden in the macro and disappears after the macro is executed? -- Bob Laughlin laughlin@cs.sfu.ca