Does author of LaTeX documents need xparse or \ExplSyntaxOn

expl3macrosxparse

If an "end-user" is preparing documents with LaTeX and using the current version of LaTeX(as of now, LaTeX2e <2021-06-01> patch level 1), which automatically loads L3 programming layer <2021-10-12>, and if the user is writing and applying macros that use \NewDocumentCommand, etc., is there any reason to either:

  1. include \usepackage{xparse}, or
  2. use \ExplSyntaxOn ?

As, for example, in the following source derived from https://tex.stackexchange.com/a/393188/13492:

\documentclass{article}

\NewDocumentCommand\test{o}{\IfNoValueTF{#1}{test}{#1}}
\begin{document}
\test[hello], and \test[hello]{\ world!}
\end{document}

I am aware, of course, of discussions such as those in What do ExplSyntaxOn and ExplSyntaxOff do?, but I am asking a practical question from a document writer's point of view, not from the point of view of a package author or LaTeX developer!

Best Answer

If you know a recent LaTeX is available then you only need to explicitly use

\usepackage{xparse}

If you want to use one of the features that were trialled in the xparse package but were not included in the final version (ltcmd) that was incorpoated into the format. Notably the g argument type. But g is evil so hopefully you won't need that.

\ExplSyntaxOn is like \makeatletter, it was never needed to access commands such as the \IfNoValueTF that you show, but just as \makeatletter allows occasional access to commands with @ in their name (which would be better in package code rather than the document), \ExplSyntaxOn allows access to commands with _ and : in their names (and some control over white space) again to access code that would probably be better in a package but can be placed in the preamble if needed.

Related Question