I'm thoroughly enjoying using LaTeX3 for programming my LaTeX stuff and the more I use it, the easier it gets and the more I shudder at returning to LaTeX2e or even pure TeX! But every now and again I find myself needing to interact with LaTeX2e at the programming level. As an example, there may be a conditional set by some LaTeX2e package that I want to test in my package written in LaTeX3. I could do this using the LaTeX2e method:
\ifcondition
<stuff>
\else
<other stuff>
\fi
but I don't like that, partly because then I have to remember to worry about \expandafter
s if I want to ensure that the \else
and \fi
don't interfere with the inner code. So I'd rather stick with the LaTeX3 syntax.
My current code for the above is:
\prg_new_conditional:Npnn \latex_if:N #1 {p,T,F,TF}
{
\if_meaning:w #1 \iftrue
\prg_return_true: \else: \prg_return_false: \fi:
}
Is this a reasonable approach, or is there a better way?
Similarly, (I hope I can get away with two questions here since they are so closely related) how should I interact with LaTeX2e macros? Let's say a package defines a macro \def\something{This is some text we'll save for later.}
and I want to mess with that using LaTeX3. Am I right in thinking that I should regard is as a token list (tl
)? Are there any pitfalls to doing so?