TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In source2e.pdf I've seen \@let@token used in several places, for example in the definition of \@ifnextchar:

\long\def\@ifnextchar#1#2#3{%
  \let\reserved@d=#1%
  \def\reserved@a{#2}%
  \def\reserved@b{#3}%
  \futurelet\@let@token\@ifnch}

However, I couldn't find a description of \@let@token, so my question is what exactly does \@let@token do?

share|improve this question
up vote 21 down vote accepted

\@let@token is assigned by \futurelet to the next token after the \@ifnextchar, i.e. it is the next character. The \futurelet\@let@token\@ifnch code means "assign the next token to \@let@token and then process \@ifnch". Inside \@ifnch the \@let@token macro is tested if it is equal to the (first token of the) first argument of \@ifnextchar, i.e. \reserved@d (see the \let\reserved@d=#1).

So, it does nothing, but it is used as a temporary variable. In theory \@tempa could have been used as well but wouldn't be as save as a named special macro. The benefit here is that you can check \@let@token in the false clause of \@ifnextchar using \ifx against other tokens without going to the more complex \@ifnextchar macro again.

\@ifnextchar{\relax}{It was a relax!}{%
   \ifx\@let@token$
      It was a dollar!
   \else
     \ifx\@let@token&
        It was an ampersand!
     \else
        something else
     \fi
   \fi
}

This is useful for parser code as in e.g. tikz-timing and ydoc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.