6

I have questions about the following functions in LaTeX3:

  • \token_if_macro_p:N
  • \token_if_long_macro_p:N
  • \token_if_protected_macro_p:N
  • \token_if_protected_long_macro_p:N

How do they behave with the following:

  • a not long, not protected macro
  • a long, not protected macro
  • a not long, protected macro
  • a long, protected macro

(that makes 16 possibilities in total).

If \token_if_long_macro_p:N returns true for a long protected macro, while \token_if_protected_macro_p:N returns false for a long protected macro why? If that is the case what is the reason behind this design choice?

1 Answer 1

6

These tests are low-level and check exactly what they say - is this macro say \protected, i.e. defined by

\protected\def

(or \edef equivalent). One would not expect to need to use these low-level tests for code arising from expl3 methods.

As such, if you test for \protected status but allow for either status for \long, you need two tests

\bool_lazy_or:nnTF
  { \token_if_protected_macro_p:N #1 }
  { \token_if_protected_long_macro_p:N #1 }

or similar.

They work by looking at the \meaning of a token, which will have an exact number of prefixes - for performance, these tests are fast and if you want combinations, it's up to you to do that.

1
  • Note: I've adjusted the docs here for the next release
    – Joseph Wright
    Commented 2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .