This is similar to a previous question (Spaces around Boolean argument to \IfValueT gives -NoValue-) but the answer to that one involved a math mode character and its catcode, whereas in this question there is no such issue.
Consider this MWE:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\testing}{ o }
{%
\IfValueTF{ #1 }
{#1}
{false}
}%
\ExplSyntaxOff
\begin{document}
\testing
\end{document}
Without the \ExplSyntaxOn...\ExplSyntaxOff and without any spaces around #1 in \IfValueTF{#1} I get the expected result (false). However, if I put spaces around the argument \IfValueTF{ #1 } I get -NoValue-, unless I also turn on \ExplSyntaxOn...\ExplSyntaxOff. This can't be a mathmode issue or catcode issue like before, at least if it is I don't understand it. Also, if I make the argument to \testing mandatory rather than optional, this doesn't happen, but I still don't get false when I expect to. What is going on in this situation? I know \NewDocumentCommand doesn't require xparse but should I included it anyway and put all my definitions inside \ExplSyntaxOn...\ExplSyntaxOff?
#1so it works. – David Carlisle Aug 13 '20 at 19:29latex-devformat. I had seen that before but didn't know what it was. – LaTeXereXeTaL Aug 13 '20 at 19:31\makeatletter: you use it if you need kernel macros. As long as you use only user-level commands noexplsyntax is necessary. But again IMO, and I'm a lousy programmer. – campa Aug 14 '20 at 16:30