Say for some reason I want to make a macro with input stream behaviour mimicking that of \afterassignment and \aftergroup. Namely, I want to absorb exactly one token from the input stream following the macro, without expanding it, regardless of whether it would be an unmatched brace, and store it somewhere I could look at it. This is almost like \[future]let but not quite: consider
\def\x{\message{Wrong}}
\afterassignment\x
\def\x{\message{Right}}
\def\save{\let\recall=}
\def\x{\message{Wrong}}
\save\x
\def\x{\message{Right}}
\recall
which outputs “Right Wrong”.
\afterassignmentin a useful manner, I should be able to define\saveso as to get BBB DDD instead. The current behaviour is totally expected, but it is not the desired one. – Alex Shpilkin Feb 13 '16 at 20:26\futurelet:\futurelet\decide\xwill expand\decide, that can do things depending on what's the following token (in this case\x. Such an action might also include removing the token from the input stream, for example if the replacement text of\decideends with\let\forget=. – egreg Feb 13 '16 at 20:37\futurelet\next\decide\xor similar.) It inherits its semantics from\let. So,\nextwill be defined to be equivalent to the current meaning of\x, not to expand to\x. If\xis redefined later,\nextwon’t pick up the redefinition. This is what the example in the question shows. – Alex Shpilkin Feb 13 '16 at 20:46\letnot\defas you can not have a mis-matched brace in a macro replacement text. – David Carlisle Feb 13 '16 at 21:40\nextwas obviously missing. You're giving contradictory requirements, I'm afraid. – egreg Feb 13 '16 at 22:05\afterassignment. – Alex Shpilkin Feb 13 '16 at 23:41\xis redefined later" can only happen from\decide.\decideexamines\nextand could alter the meaning of\x(if it is a macro), but then obviously it knows what it is doing, no ? Note also that if the token is a character token its catcode will be frozen by the\futurelet, it can not be changed from within\decide. – Feb 16 '16 at 22:25