The first argument to
\NewDocumentCommand
can only be
one command sequence token and not – like in your case – an instruction to build one. This means you have to build the command sequence token
before passing it to
\NewDocumentCommand
.
Also you are not following expl3 guidelines and naming conventions. Here is a working suggestion:
Code: Select all
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\cs_new:Npn \ewann_impl:n #1 { (#1) }
\cs_new_protected:Npn \ewann_metamacro:n #1
{
\exp_args:Nc \NewDocumentCommand {#1} {}
{ \ewann_impl:n {#1} }
}
\NewDocumentCommand \metamacro {m}
{ \ewann_metamacro:n {#1} }
\ExplSyntaxOff
\begin{document}
\metamacro{baz}
\baz % Expected: (baz)
\end{document}