In this answer, @UlrichDiez created a macro \InnerCreateTheorem, as follows:
\NewDocumentCommand{\InnerCreateTheorem}{mmmod<>}{%
% #1 = star or no star
% #2 = name of environment
% #3 = emptiness or star to append to name of environment
% #4 = numbered like
% #5 = numbered within
\IfBooleanTF{#1}{%
\IfValueTF{#4}{\@firstoftwo}{\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}%
}{\IfValueTF{#4}{\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}{\@secondoftwo}}%
{%
\GenericError{}%
{\string\CreateTheorem\space syntax error\on@line}%
{You cannot call the starred variant with optional arguments.\MessageBreak
You cannot call the unstarred variant with several optional arguments.}%
{%
Allowed usage:\MessageBreak\MessageBreak
\CreateTheorem*{(name of environment)}\MessageBreak
\CreateTheorem{(name of environment)}[(numbered like)]\MessageBreak
\CreateTheorem{(name of environment)}<(numbered within)>\MessageBreak
\CreateTheorem{(name of environment)}\MessageBreak
Captions come from macros \string\(name of environment)nameEN\MessageBreak
respective \string\(name of environment)nameFR.\MessageBreak
These macros must be defined separately.%
}%
}{%
%% ...
}%
}%
However, I was confused about this. As I understood (according to this question), \@firstoftwo corresponds to {\GenericError ...} and \@secondoftwo corresponds to {%%...}. But \GenericError seems to have four cases, so under which circumstances would each one show up?
mandatory. – Werner Mar 08 '21 at 04:29\IfBooleanTF{#1}and state in the comments that argument#1is an optional star/not. However, that would require a parameter specification that resemblessmmod<>, notmmmod<>. – Werner Mar 08 '21 at 05:27sis processed in\CreateTheorem, which then calls the\InnerCreateTheoremabove with{*}or{}(I didn't add the definition of\CreateTheoremhere because it is irrelevant to this question). I doubt if this is the best way, but it certainly works. – Jinwen Mar 08 '21 at 05:30\InnerCreateTheorem's test on#1is not\IfValueTFbut is\IfBooleanTF. The first argument,#1, is passed in by another macro (\CreateTheorem) and holds tokens denoting the value of the boolean after evaluating that other macro'ss-type-argument. So it denotes whether in the other macro (\CreateTheorem) a star was present or not. Thus that condition is not superfluous. – Ulrich Diez Mar 08 '21 at 17:25\CreateTheoremiss-type. This means: In case there is no star,#1of\CreateTheoremconsists of tokens that denote the boolean-value "false". In case there is a star,#1of\CreateTheoremconsists of tokens that denote the boolean-value "true". These tokens are passed on to\InnerCreateTheoremas it's 1st argument, anm-type-argument. So\InnerCreateTheoremcan fork whether in\CreateTheorema star was present by evaluating its 1st argument via\IfBooleanTF. (Not\IfValueTFwhich is used for testingo-type arguments, btw.) This ... – Ulrich Diez Mar 08 '21 at 17:38{*}/{}.{*}/{}is passed as 3rd argument to\InnerCreateTheoremdepending on whether the name of the environment to define ends with a star or not.{*}/{}is needed because you commented that you wishfooEN*, notfoo*EN. In the hope that it clarifies things a bit I added some commenting about the meaning of arguments in my answer referred by you. I should have done this earlier, so I apologize. – Ulrich Diez Mar 08 '21 at 18:15