9

On p. 95 of my interface3 documentation, dated July 28, 2013, the \tl_case:??? function is first introduced as having a signature \tl_case:NnnTF, but on its extended description for usage it appears as \tl_case:NnTF. I guess this is a typo, but just in case... is it?

My question is actually about the possibility to use this switch-like flow control structure for testing the content of a token list variable against the contents of a collection of token lists, whereas what I understand we have now is a test against the contents of a collection of token list variables. Please, amend my understanding if I got it wrong.

Btw, it is not clear to me from the documentation whether or not the testing stops after the first success (if any). This point may not make any sense in regard to testing against token lists but it definitely does when testing against token lists variables, since we could have more than just one variable set to the same content.

4

The \tl_case:NnnTF in the left margin is a typo; it should be \tl_case:NnTF which agrees with the description in the main text.

The old function \tl_case:Nnn has recently been renamed into \tl_case:NnF and an argument for adding actions in the “true” case (that is, when a match occurs) has found its place.

The TF is optional, in the sense that there is a total of four functions:

\tl_case:NnTF
\tl_case:NnT
\tl_case:NnF
\tl_case:Nn

All of them do a match of a token list variable against token list variables, which is the only way to ensure full expandability.

If you need to do a matching with character strings, there are the similar functions

\str_case:nn(TF)

(where (TF) stands for empty, T, F or TF) and

\str_case_x:nn(TF)

The difference is that the latter tries complete expansion on the argument strings. (Note that there is a misprint in the description of \str_case:nnTF in the manual.)

As indicated by Joseph Wright, the tests do stop on first hit: they are essentially loops with a break condition (so they are expandable).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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