home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / text / tex / 14283 < prev    next >
Encoding:
Text File  |  1992-12-17  |  4.2 KB  |  119 lines

  1. 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
  2. From: MJD@MATH.AMS.ORG (Michael Downes)
  3. Newsgroups: comp.text.tex
  4. Subject: Re:  TeX's memory
  5. Message-ID: <724610758.196548.MJD@math.ams.org>
  6. Date: 17 Dec 92 16:45:58 GMT
  7. Organization: Info-Tex<==>Comp.Text.Tex Gateway
  8. Lines: 108
  9. X-Gateway-Source-Info: Mailing List
  10.  
  11. Arthur Ogawa writes:
  12.  
  13. > By the way, concerning \csnames: It is true that TeX never yields up
  14. > space in the hash table (where control sequence names, but not their meanings
  15. > are stored). It is interesting to note that the mere act of testing
  16. > whether a \csname is defined, as in
  17. >
  18. > \ifx\foo\undefined
  19. >
  20. > will make an entry for \foo in the hash table, and thereby use up additional
  21. > space for "multiletter control sequence names".
  22.  
  23. Quibbling, quibbling, here I go, but perhaps some of what follows will
  24. be of general interest. The example as given is inaccurate; probably
  25. you had in mind the test
  26.  
  27.   \expandafter\ifx\csname foo\endcsname\relax
  28.  
  29. which is at the heart of LaTeX's \@ifundefined function.
  30. \ifx\foo\undefined does not enter either \foo or \undefined into the
  31. hash table: `TeX does not put undefined control sequences into its
  32. internal tables if they follow \ifx or if they are encountered while
  33. skipping conditional text.' [TeXbook, Appendix D, p384]
  34.  
  35. This can be verified with multiple runs of the test file given below.
  36.  
  37. Michael Downes                              mjd@math.ams.org (Internet)
  38.  
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40. %    hashtest.tex, for use with Plain TeX
  41. %    {17-Dec-1992}{mjd}
  42. %
  43. %    Run first as is and look at the number of multiletter control
  44. %    sequences reported in the log file; this is the reference number
  45. %    for subsequent runs.  You may want to make a copy of this and the
  46. %    subsequent log files for comparison.
  47. %
  48. %    To see the hash table statistics for case number 1, delete %1%
  49. %    (or replace it with ^^@) and run TeX again, then look at the log
  50. %    file. Likewise for the other cases.
  51.  
  52. \tracingstats=1
  53.  
  54. %0%% Case 0: Number of control sequences is currently 922 for TeX
  55. %0%% 3.14... and a recent version of plain.tex.
  56.  
  57. %    \ifx does not add its two argument control sequences to the hash
  58. %    table.
  59. %1%\ifx\foo\undefined
  60. %1%\message{foo is undefined}
  61. %1%\fi
  62.  
  63. %    But \csname does add the created control sequence to the hash
  64. %    table, and the \csname here is completed before the \ifx is
  65. %    applied, because of the \expandafter.
  66. %2%\expandafter\ifx\csname foo\endcsname\relax
  67. %2%\message{foo is undefined}
  68. %2%\fi
  69.  
  70. %    If an undefined control sequence is executed directly you get an
  71. %    error message but the control sequence name is not entered into
  72. %    the hash table.
  73. %3%\foo % <return> to continue
  74.  
  75. %    If an undefined control sequence is read as the argument of a
  76. %    macro, it *is* entered into the hash table.
  77. %4%\showhyphens{hash\foo table}% <return> to continue
  78.  
  79. %    But the arguments of certain primitive commands such as \message
  80. %    are not the same as macro arguments:
  81. %5%\message{\foo is undefined}% <return> to continue
  82.  
  83. %    The \string operation adds its argument to the hash table. This
  84. %    seems unnecessary.
  85. %6%\message{\string\foo\space is undefined}
  86.  
  87. %    \noexpand does not keep a control sequence from being added to
  88. %    the hash table.
  89. %7%\message{\noexpand\foo is undefined}
  90.  
  91. %    Control sequences on the false branch of an \if must be tokenized
  92. %    in order for TeX to be able to properly match up \fi, \else, and
  93. %    \if's; but TeX does not add an undefined control sequence to the
  94. %    hash table if it is found on the false branch of a conditional.
  95. %8%\ifx\foo\undefined
  96. %8%  \message{foo is undefined}
  97. %8%\else
  98. %8%  \let\foo=\relax
  99. %8%\fi
  100.  
  101. %    Single-character control sequences are not counted in the hash
  102. %    table.
  103. %9%\def\0{0}\def\1{1}\def\A{A}\def\B{B}
  104.  
  105. %    An undefined control sequence in the replacement text of a
  106. %    definition is added to the hash table, whether or not the defined
  107. %    macro is ever used.
  108. %10%\def\0{\foo}
  109.  
  110. %    And an undefined control sequence in the parameter text of a
  111. %    definition is also added to the hash table.
  112. %11%\def\0#1\foo{\relax}
  113.  
  114. %    Finally, a control sequence entered into a token register also is
  115. %    added to the hash table:
  116. \toks0={\foo}
  117.  
  118. \end
  119.