In my LaTeX laboratory I am doing weird experiments with expl3 (just started to use it some days ago, so regarding l3 I am complete newbie)
I am trying to generate command sequence within of another macro, the name being based on macro argument(s) of the outer macro.
In LaTeX(2e) this is easy
\newcommand{\foo}[1]{%
\expandafter\newcommand\csname foo#1\endcsname{Hello World}
}
and \foo{bar} would define \foobar (being not really useful here, of course)
I tried to apply this way (replacing \expandafter with \exp_after:wN) to a expl3 command sequence with \cs_new:Nn and it works, but I want to know:
Is there a better, cleaner way to get this in
expl3, without using\csnameetc., just from the signature or using variants?
P.S. I am aware, that expl3 commands are not really meant for typesetting, the output of Hello World is just an example.
\documentclass{article}
% Module named foo ;-)
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\foo}{m}{%
\exp_after:wN\cs_new:Nn \csname foo_#1:\endcsname {Hello\space World}
}
\NewDocumentCommand{\foocall}{}{%
\foo{start} % define \foo_start:
\foo_start:
}
\ExplSyntaxOff
\begin{document}
\foocall
\end{document}
A not really similar question about the expansion is Generalizing macros with LaTeX3, so I don't think my question is a duplicate.

\cs_new:cn { foo_#1: } { Hello ~ world }. Or may be in this case\tl_set:cn { l_foo_#1_tl } { Hello ~ world }. – Manuel Jul 26 '15 at 09:06\cs_new:cn {foo_#1:}... I was failing using the:cnsignature, because I omit the{...}pair aroundfoo_#1:... – Jul 26 '15 at 09:08\tl_set:cn? – Jul 26 '15 at 09:13\whatever foo_#1:will takefas the first argument of\whatever. Well, the advantage of setting it as a token list is that it can contain#for instance, but, in any case, what matters is that if it is a token list you should set it as a token list, andHello ~ worldlooks like a token list to me :) – Manuel Jul 26 '15 at 09:21\foo_#1:is only a very simplified example. There is more internal setup actually and there is basically more work to do internally, as well as\foo_#1would have some more arguments. – Jul 26 '15 at 09:24%at all inside\ExplSyntax(On|Off). – Manuel Jul 26 '15 at 09:26%in future. – Jul 26 '15 at 09:31\exp_after:wNyou're most likely using expl3 the wrong way. :) Almost always expl3 has more elegant (and more readable) ways of doing things... – cgnieder Jul 26 '15 at 10:23Nandntype arguments only and create the needed variants thereof later – cgnieder Jul 26 '15 at 10:35l3, so it's like a new language to me ;-) – Jul 26 '15 at 10:37expl3of course. – Jul 26 '15 at 22:58