I was living in the delusion that the "token equality" tested by
\ifx was the only thing you need to remember about this subject, but this week I learned otherwise (thanks to David Carlisle).
Now I'm wondering how many fundamentally different concepts of "token equivalence" there are?
So far I know two:
Two characters are equal when they have the same character code and catcode, two cs names are equal when they are both undefined or are both "let to the same thing", a cs name is equal to a character iff it has been
\letto it, ...
Test in delimited argument.
Two characters are equal when they have the same character code and catcode, two cs names are equal when they have the same name, a character is never equal to a cs name, ...
But my knowledge is obviously fragmentary. I'd like to have the whole picture.
It's hard to find out about such things in the TeXbook.
I'd like to ask for one answer per fundamentally different concept of token equality.
Each answer should specify
- In what context this concept is invoked.
- Which tokens are equal and which are not.
- Is this arbitrary or is there a rationale behind this (as opposed to making everything work as with
- Is there any neat trick with which this can be exploited?
Just to be sure: I'd also like answers on the two examples I mentioned, as my knowledge is obviously limited...