For gaining deeper understanding of TeX I recommend reading the TeXbook, being very picky about the context of every word while reading and strictly sticking to correctly using the terminology introduced in that book.
The guide of programming referenced by you uses its own home-brewed terminology which lacks of precision and therefore may be misleading for novices.
E.g., you find explanations like
But neither is explained what "contents" in the phrase "contents of a macro" means, nor is explained what "as it is seen by TeX" means.
Besides this, applying \meaning
actually is not restricted to macros. \meaning
can be applied to a ⟨token⟩ which is not a ⟨macro⟩ as well: You can use \meaning
for finding out about the meanings of primitives, explicit character-tokens, implicit character-tokens, \chardef
-tokens, \toksdef
-tokens, \dimendef
-tokens, whatsoever \...def
-tokens, ...
A novice cannot deduce that characters occurring in the .tex-input-file may have been discarded at the time of tokenizing the definition of the macro whose \meaning
is to be delivered because at that time those characters were of category code 10(space) and thus got discarded in moments where the reading-apparatus was in state S(skipping blanks) or N(new line).
A novice cannot deduce that \meaning
just delivers a sequence of explicit character-tokens of category 12(other) with spaces being the only exception: Spaces will be of category 10(space). I.e., \meaning
does not give you clues which of the character-tokens it delivers come from control-word-tokens or control-symbol-tokens and which of the character-tokens it delivers come from explicit character-tokens. Besides this, with explicit character-tokens you loose information about categories. Routines for patching macros that are based on \meaning
actually just do some sort of "very educated guessing".
A novice cannot deduce that the result of \meaning
is affected by the value of the integer-parameter \escapechar
.
A novice cannot deduce that the result of \meaning
may be affected by category codes that are current at the time of carrying out \meaning
: When \meaning
delivers the symbolic representation of a control-symbol-token, no space-token is appended. When \meaning
delivers the symbolic representation of a control-word-token, a space-token is appended. Whether a control-sequence-token whose name consists of a single character is treated as a control-symbol-token or as control-word-token depends on the category-code of that character current at the time of carrying out \meaning
:
\def\test{\z\z W\z}
\tt
\string\test=\meaning\test
\catcode`\z=12
\string\test=\meaning\test
\escapechar=`\A
\catcode`\z=11
\string\test=\meaning\test
\catcode`\z=12
\string\test=\meaning\test
\bigskip
\hrule
\bigskip
\escapechar=`\\
\catcode`\z=11
\def\testA{\z\zW \z}
\def\testB{\z\z W \z}
\catcode`\z=12
\string\testA=\meaning\testA
\string\testB=\meaning\testB
meanings are \ifx\testA\testB equal\else different\fi
\bye
TeXbook, Chapter 7: How TeX Reads What You Type clearly says:
In the examples so far, \string
has converted control sequences into lists of tokens that begin with \12
. But this backslash token isn't really hardwired into TeX; there’s a parameter called \escapechar
that specifies what character should be used when control sequences are output as text. The value of \escapechar
is normally TeX’s internal code for backslash, but it can be changed if another convention is desired.
This paragraph is a nice example on why I suggest being very picky while reading the book: Although in the beginning the paragraph is about \string
it is not said that \string
is the only routine where outputting control sequences as text plays a rôle.
\meaning
, too, is such a routine.
TeXbook, Chapter 20: Definitions (also called Macros) clearly says:
\meaning⟨token⟩
. TeX expands this to the sequence of characters that would be displayed on your terminal by the commands ‘\let\test=⟨token⟩ \show\test
’. For example, ‘\meaning A
’ usually expands to ‘the letter A
’; ‘\meaning\A
’ after ‘\def\A#1B{\C}
’ expands to ‘macro:#1B->\C
’.
[...]
In all of the cases listed so far, \the
produces a result that is a sequence of ASCII character tokens. Category code 12 (“other”) is assigned to each token, except that character code 32 gets category 10 (“space”). The same rule is used to assign category codes to the tokens produced by \number
, \romannumeral
, \string
, \meaning
, \jobname
, and \fontname
.
TeXbook, Chapter 21: Making Boxes clearly says:
Each \write
command produces output in the form that TeX always uses to display token lists symbolically: Characters represent themselves (except that you get duplicated characters like ##
for macro parameter characters); unexpandable control sequence tokens produce their names, preceded by the \escapechar
and followed by a space (unless the name is an active character or a control sequence formed from a single nonletter).
Another example where pickiness while reading is a good thing: Although in the beginning the paragraph is about \write
it is not said that \write
is the only routine where displaying token lists symbolically plays a rôle.
\meaning
, too, is such a routine.
\meaning
, however, does not duplicate macro-parameter-characters.
Perhaps the word "except" is intended to indicate that this duplication is a deviation of the form of displaying token-lists symbolically which occurs when using \write
for writing things (to text-file or terminal).
\scantokens
to reparse the string) but it is not possible to do this in general, for example you can not reliably determine any delimited arguments that the macro may have from\meaning
(or anything else)