\somepenalty=10000 vs. \somepenalty 10000 vs. \somepenalty10000
There is no difference. The syntax for a primitive tex assignments allows an option =
(and optional space)
Note that
\interlinepenalty 10000 or \interlinepenalty10000
are the same for a different reason, the space after a command name is never tokenized at all it just terminates the command so these make the same tokens.
Conversely
\interlinepenalty= 10000
the space after = is tokenized but is ignored as the assignment absorbs optional equals optionally followed by a space.
David C. explained that there is no differences between these three alternatives because of TeX syntax rules (the optional =
) or because of the toknizer outputs the same result in case 2 and 3. But you have asked why? The reason is: The optional =
is used because this is more understandable by humans. In old days (when TeX was born) each byte was counted. So: the =
was not used in the macro bodies because these token strings must be saved into the memory. But this optional =
was used outside macro bodies. Today, there is no such memory limitations, the usage of =
is recommended.
Your second question: is there any case when =
cannot be used. Yes. If the syntax context is not assignment. For example \penalty 10000
. The primitive command \penalty
is not primitive register, so this is not assignment but this is command to do something in vertical or horizontal list. You cannot use =
here.
My last comment: the optional =
may have optional space around it (one space left and one right of the =
. So, \interlinepenalty= 10000
is also possible. And
\interlinepanalty = 10000
is also possible, because there is no space before =
and only one space after the =
character because the tokenizer converts this to \interlinepenalty= 10000
.
Unless I overlooked it within the answers given already, one open question remained: are there cases where the =
is required? Yes, for example if you want to do
\let\foo $ % fine
\let\bar = % incomplete
\let\baz !
In the above \bar
will be let to \let
and not to an equal sign, so you would need
\let\bar = =
(with or without the spaces).
Even more tricky: \let
something to a "space" token (exercise for the reader).