[net.text] a question for TeXperts: selective loading of macros

podar@sbcs.UUCP (Sunil Podar) (03/03/86)

I have a question for TeXperts.
The TeXbook talks about selective loading of macros and various
ways to accomplish it. I thought up of one more way but since I am
not a TeXpert (yet) I am unsure of the implications of such a
technique. I would appreciate any comments.

Having indulged in mlisp (ala EMACS) I wondered if it was possible
to simulate its autoload function in TeX/LaTeX.

Suppose we have a little file called mymac.tex which defines a
macro \mymacro. Also I have another file called autoload.tex. 

autoload.tex contains the following line(s).
%
\def\mymacro{\input{/users/podar/texlib/mymac}\mymacro}
...
maybe other similar definitions for other macros, perhaps with
different file names.
%

mymac.tex contains the definition of \mymacro, let's say:
%
\gdef\mymacro#1{\message{#1}}
...
maybe some more macros, all \gdef'd.
%

Now, you see, In my actualtext.tex, all I have to say at the
beginning is \input{.../autoload} and then the first time I use
\mymacro, the file mymac.tex will be loaded, my macro executed (I
can add parameters to the definition without any problem; actually that
might be unnecessary), and subsequently the macro will be redefined to
its proper definition.

The macros thus defined in the mymac.tex file have to be gdef'ed
otherwise they will not be defined properly (in the outer mode) if
they were not invoked from the outermost level.
Also, if the file mymac.tex contains other macro definitions, all
gdef'ed, then they all also get loaded, circumventing any load
definitions in autoload.tex.

Is this a sound idea? If so, then this is a neat way of doing
selective loading of macros. The only problem I see is that they
all have to be global definitions.

This should perhaps be mailed to unix-tex list, but I do not have
access to it and the texhax list has been dormant for a long time.
I'll appreciate any responses, and please mail them to me, unless
you choose to decide otherwise. If necessary, I'll post a summary.
-- 
Sunil Podar
SUNY at Stony Brook

CSNET: podar@sbcs.csnet
ARPA: podar%suny-sb.csnet@csnet-relay.arpa
UUCP: {allegra, hocsd, philabs, ogcvax}!sbcs!podar

jjhnsn@ut-ngp.UUCP (03/08/86)

> I have a question for TeXperts.

No, No, NO! There is no such thing as a TeXpert.
See the answer to Exercise 1.1 in the TeXbook.

	jj (I use nroff and ditroff)
--
James Lee Johnson, UTexas Computation Center, Austin, Texas 78712
ARPA:  jjhnsn@ngp.UTEXAS.EDU        jjhnsn@ut-ngp.ARPA
UUCP:  ihnp4!ut-ngp!jjhnsn  allegra!ut-ngp!jjhnsn  gatech!ut-ngp!jjhnsn
       seismo!ut-sally!jjhnsn  harvard!ut-sally!jjhnsn