4

The description of the \tl_count:n {<tokens>} function on p. 42 of The LaTeX3 Interfaces document (released 2017/09/18) includes the following sentence:

This process ignores any unprotected spaces within <tokens>.

What are unprotected spaces?

5

Here the documentation means 'protected from loss' not anything to do with engine protection from expansion. Looping over tokens in TeX usually loses spaces, unless one takes particular precautions. A space in a token list can be protected from that if it is in braces, for example

\tl_count:n { ab ~ cd }     % 4
\tl_count:n { ab { ~ } cd } % 5 

as \tl_count:n works on a 'number of items' basis.

  • Thanks. But won't you get a count of 5 even if the interior braces contain nothing at all, or any other arbitrary sequence of tokens? – Evan Aad Sep 26 '17 at 6:38
  • @EvanAad Yes, also {xyz} instead of {~} would yield the same count. – egreg Sep 26 '17 at 6:54
  • 1
    @egreg: Then I find the word "protected" to be confusing. In fact, the entire sentence "This process ignores any unprotected spaces within <tokens>." is confusing, and should be deleted, in my opinion. It suffices to say, as the documentation indeed says, that this function counts items. Both the facts that "unprotected" spaces are ignored and that "protected" spaces are not ignored is a consequence of the definition of an item. – Evan Aad Sep 26 '17 at 7:03
  • @EvanAad We've had quite a bit of discussion about 'items': quite possibility the text here predates them. (\tl_head:n has been through a number of implementations.) – Joseph Wright Sep 26 '17 at 7:11

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.