A slight variation of egreg's answer lets you specify at the time of calling \definepseudonym the default in case of not providing an optional argument:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\definepseudonym}{mO{pseudonym}mm}
{% #1 = command name
% #2 = default used in case of not providing the optional argument
% #3 = pseudonym
% #4 = other names
\exp_args:Nc{\NewDocumentCommand}{#1}{O{#2}}
{
\prop_item:cn { g_pseudonym_#1_prop } { ##1 }
}
\prop_gclear_new:c { g_pseudonym_#1_prop }
\prop_gset_from_keyval:cn { g_pseudonym_#1_prop } { #4 }
\prop_gput:cnn { g_pseudonym_#1_prop } { pseudonym } { #3 }
}
\ExplSyntaxOff
\definepseudonym{AnGo}[pseudonym]{Edwin Smith}{
sh=Ted,
real=Antonio Gonzalez,
birthplace=Somewhere,
}
\begin{document}
\AnGo[real] was known as \AnGo[pseudonym] abbreviated in \AnGo[sh].
He was born in \AnGo[birthplace].
Applying \verb|\AnGo| without optional argument yields the pseudonym: \AnGo
This is because within \verb|\definepseudonym|'s second argument, which is
optional, "pseudonym" was specified as the default which is to be used when
not providing an optional argument.
If instead of "pseudonym", e.g., "real" was specified here, then
\verb|\AnGo| without optional argument would yield the real
name/the value of the "real"-property.
\end{document}
Another variation where the "pseudonym"-property is not treated separately from other properties/other names:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\definepseudonym}{mO{pseudonym}m}
{% #1 = command name
% #2 = default used in case of not providing the optional argument
% #3 = property-value-list
\exp_args:Nc{\NewDocumentCommand}{#1}{O{#2}}
{
\prop_item:cn { g_pseudonym_#1_prop } { ##1 }
}
\prop_gclear_new:c { g_pseudonym_#1_prop }
\prop_gset_from_keyval:cn { g_pseudonym_#1_prop } { #3 }
}
\ExplSyntaxOff
\definepseudonym{AnGo}[pseudonym]{
pseudonym=Edwin Smith,
sh=Ted,
real=Antonio Gonzalez,
birthplace=Somewhere,
}
\begin{document}
\AnGo[real] was known as \AnGo[pseudonym] abbreviated in \AnGo[sh].
He was born in \AnGo[birthplace].
Applying \verb|\AnGo| without optional argument yields the pseudonym: \AnGo
This is because within \verb|\definepseudonym|'s second argument, which is
optional, "pseudonym" was specified as the default which is to be used when
not providing an optional argument.
If instead of "pseudonym", e.g., "real" was specified here, then
\verb|\AnGo| without optional argument would yield the real
name/the value of the "real"-property.
\end{document}
Yet another variation could be letting you specify a global default-value for the optional argument of a pseudonym-macro which at the time of calling \definepseudonym can be overridden via also specifying the default-property within \definepseudonym's second argument:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\cs_generate_variant:Nn \prop_item:Nn {cx}
\tl_new:N {\jan_GlobalPseudonymDefault}
\tl_gset:Nn {\jan_GlobalPseudonymDefault} {pseudonym}
\NewDocumentCommand{\SetGlobalPseudonymDefault}{m}{\tl_gset:Nn {\jan_GlobalPseudonymDefault} {#1}}
\NewDocumentCommand{\definepseudonym}{mm}
{% #1 = command name
% #2 = property-value-list
\exp_args:Nc{\NewDocumentCommand}{#1}{O{default}}
{
\prop_item:cn { g_pseudonym_#1_prop } { ##1 }
}
\prop_gclear_new:c { g_pseudonym_#1_prop }
\prop_gset_from_keyval:cn { g_pseudonym_#1_prop } { #2 }
\prop_if_in:cnTF{ g_pseudonym_#1_prop }{ default }{}{%
\prop_gput:cnV { g_pseudonym_#1_prop } { default } { \jan_GlobalPseudonymDefault }
}
\prop_gput:cnx { g_pseudonym_#1_prop } { default }
{ \prop_item:cx { g_pseudonym_#1_prop } { \prop_item:cn { g_pseudonym_#1_prop } { default } } }
}
\ExplSyntaxOff
% The global default is initialized to "peseudonym" but we change it
% to the real name:
\SetGlobalPseudonymDefault{real}
\definepseudonym{AnGo}{
pseudonym=Edwin Smith,
sh=Ted,
real=Antonio Gonzalez,
birthplace=Somewhere,
% Override the global default:
%default=sh,
default=pseudonym,
}
\begin{document}
\AnGo[real] was known as \AnGo[pseudonym] abbreviated in \AnGo[sh].
He was born in \AnGo[birthplace].
Applying \verb|\AnGo| without optional argument yields the pseudonym: \AnGo
This is because within \verb|\definepseudonym|'s second argument, pseudonym
was specified as the value of the default-property.
If the default-property would not have been specified here, it would have
got the value stored in \verb|\jan_GlobalPseudonymDefault|, which in turn
can be changed globally via \verb|\SetGlobalPseudonymDefault|.
\end{document}
\definepseudonym{}{}{}{}...). A way to have it both ways? So I could do\definepseudonym{AnGo}{Edwin Smith}{Ted}{}{Somewhere}leaving blank those arguments I don't need/want to reveal. – jan Apr 29 '19 at 13:55\newcommand{\newpseudonym}[5]{\definepseudonym{#1}{#2}{sh=#3,real=#4,birthplace=#5}}since\newcommandcan't have more than one optional argument but I'm unfamiliar with thexparsesyntax ...) – jan Apr 29 '19 at 13:55pseudonym=Edwin Smith(so that only the command itself is mandatory)? – jan Apr 29 '19 at 16:44