This is my first question here on TeXSE, and my second question on the StackExchange community. I am reading Notes on Programming in TeX by Dr. Christian Feuersänger as part of a general introduction to TeX; I've been using LaTeX for about a year, and I want to learn in general terms how the TeX system works, i.e. macros, counters, groups, etc. Indeed, after this document I plan to read TeX for the Impatient for a more thorough introduction to the system.
Subsections 2.1 through 2.4 from the Notes briefly discuss macros, counters and tokens, but I don't quite understand what is the difference between a counter and a token. Counters can store an integer value, and can be incremented/decremented by x with the syntax \advance\count0 by x, where \count0 is a previously defined counter. What does each do? How does TeX understand each one? Which purposes do both serve?
Thanks
Edit:
Thanks for the answers. Relating to the one from Phelype Oleinik, sorry, what I meant with tokens is instead registers. Feuersänger says the following regarding registers:
There are also 255 token registers which can be thought of as special string variables. Of course, every macro assignment
\def\macro{content}is also some kind of string variable, but token registers are special: their contents won't be expanded when used with\the\toks<number>. This can be used for fine grained expansion control, see Section 2.3 below (p. 3).
Further, he gives the example
\toks0={abc}%
\toks1={DEF}%
The value is now \the\toks0 \the\toks1.
A counter cannot clearly store the literals abc, but what is then the difference between registers and macros, when one uses a macro to store some control sequence, i. e. just a plain word? Both expand to their content, right?
\advance\count0 by xcontains the 8 tokens:\advance,\count,0,<space>,b,y,<space>,x. Other than that, I don't think I understand your question. – Phelype Oleinik Dec 15 '21 at 01:49\byte is the default escape character). This is why multi-byte entities such as\advanceand\countconstitute single tokens. Reference: https://en.wikibooks.org/wiki/TeX/catcode – Steven B. Segletes Dec 15 '21 at 03:40t,e,x,twill typesettextin the current font, location, colour; a macro is a token that expands to its definition (itself a token stream, and which may have more macros, and/or primitives, and/or text) and may or may not take parameters. A group,{...}, is local: what happens in the group stays in the group, e.g. font change (unless global actions are occurring). – Cicada Dec 15 '21 at 06:16