home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!sdd.hp.com!usc!news.service.uci.edu!unogate!mvb.saic.com!info-tex
- From: MJD@MATH.AMS.ORG (Michael Downes)
- Newsgroups: comp.text.tex
- Subject: Re: TeX's memory
- Message-ID: <724610758.196548.MJD@math.ams.org>
- Date: 17 Dec 92 16:45:58 GMT
- Organization: Info-Tex<==>Comp.Text.Tex Gateway
- Lines: 108
- X-Gateway-Source-Info: Mailing List
-
- Arthur Ogawa writes:
-
- > By the way, concerning \csnames: It is true that TeX never yields up
- > space in the hash table (where control sequence names, but not their meanings
- > are stored). It is interesting to note that the mere act of testing
- > whether a \csname is defined, as in
- >
- > \ifx\foo\undefined
- >
- > will make an entry for \foo in the hash table, and thereby use up additional
- > space for "multiletter control sequence names".
-
- Quibbling, quibbling, here I go, but perhaps some of what follows will
- be of general interest. The example as given is inaccurate; probably
- you had in mind the test
-
- \expandafter\ifx\csname foo\endcsname\relax
-
- which is at the heart of LaTeX's \@ifundefined function.
- \ifx\foo\undefined does not enter either \foo or \undefined into the
- hash table: `TeX does not put undefined control sequences into its
- internal tables if they follow \ifx or if they are encountered while
- skipping conditional text.' [TeXbook, Appendix D, p384]
-
- This can be verified with multiple runs of the test file given below.
-
- Michael Downes mjd@math.ams.org (Internet)
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % hashtest.tex, for use with Plain TeX
- % {17-Dec-1992}{mjd}
- %
- % Run first as is and look at the number of multiletter control
- % sequences reported in the log file; this is the reference number
- % for subsequent runs. You may want to make a copy of this and the
- % subsequent log files for comparison.
- %
- % To see the hash table statistics for case number 1, delete %1%
- % (or replace it with ^^@) and run TeX again, then look at the log
- % file. Likewise for the other cases.
-
- \tracingstats=1
-
- %0%% Case 0: Number of control sequences is currently 922 for TeX
- %0%% 3.14... and a recent version of plain.tex.
-
- % \ifx does not add its two argument control sequences to the hash
- % table.
- %1%\ifx\foo\undefined
- %1%\message{foo is undefined}
- %1%\fi
-
- % But \csname does add the created control sequence to the hash
- % table, and the \csname here is completed before the \ifx is
- % applied, because of the \expandafter.
- %2%\expandafter\ifx\csname foo\endcsname\relax
- %2%\message{foo is undefined}
- %2%\fi
-
- % If an undefined control sequence is executed directly you get an
- % error message but the control sequence name is not entered into
- % the hash table.
- %3%\foo % <return> to continue
-
- % If an undefined control sequence is read as the argument of a
- % macro, it *is* entered into the hash table.
- %4%\showhyphens{hash\foo table}% <return> to continue
-
- % But the arguments of certain primitive commands such as \message
- % are not the same as macro arguments:
- %5%\message{\foo is undefined}% <return> to continue
-
- % The \string operation adds its argument to the hash table. This
- % seems unnecessary.
- %6%\message{\string\foo\space is undefined}
-
- % \noexpand does not keep a control sequence from being added to
- % the hash table.
- %7%\message{\noexpand\foo is undefined}
-
- % Control sequences on the false branch of an \if must be tokenized
- % in order for TeX to be able to properly match up \fi, \else, and
- % \if's; but TeX does not add an undefined control sequence to the
- % hash table if it is found on the false branch of a conditional.
- %8%\ifx\foo\undefined
- %8% \message{foo is undefined}
- %8%\else
- %8% \let\foo=\relax
- %8%\fi
-
- % Single-character control sequences are not counted in the hash
- % table.
- %9%\def\0{0}\def\1{1}\def\A{A}\def\B{B}
-
- % An undefined control sequence in the replacement text of a
- % definition is added to the hash table, whether or not the defined
- % macro is ever used.
- %10%\def\0{\foo}
-
- % And an undefined control sequence in the parameter text of a
- % definition is also added to the hash table.
- %11%\def\0#1\foo{\relax}
-
- % Finally, a control sequence entered into a token register also is
- % added to the hash table:
- \toks0={\foo}
-
- \end
-