The function you mention has a name consisting of three parts: cs
, set
and eq
.
cs
is the “module name”: the function deals with functions (for definitions and things alike); cs
stands for “control sequence”, probably it's not the best name, but it's too late for changing it.
set
is the main action type; in this module there are basically three action types: new
, set
and gset
: the first one is for globally defining new functions, checking that the name is not already used; the second and third ones do a definition or redefinition with no check, the difference is that set
acts locally (in the scope of the current group), whereas gset
does the definition or redefinition globally.
eq
is how the definition is performed and stands for “equal”.
Thus the name can be read as “locally define a function to be a copy of some already existing one.
Next comes the “signature“, in this case :NN
, which means that the function \cs_set_eq:NN
should be followed by two unbraced function names.
Not only it makes visual syntax checking straighforward, but it is internally used for defining variants. We can compare it with what is available with other tools, standard LaTeX and etoolbox
:
\let\foo\baz
\letcs\foo{baz}
\cslet{foo}\baz
\csletcs{foo}{baz}
All four perform the same task; of course, the three commands provided by etoolbox
are used when one or both names need to be constructed from arguments to other macros. With expl3
we have the c
argument type to denote a control sequence whose name should be formed by the token in a braced argument (internally using, of course \csname...\endcsname
):
\cs_set_eq:NN \carla_foo:n \carla_baz:n
\cs_set_eq:Nc \carla_foo:n {carla_baz:n}
\cs_set_eq:cN {carla_foo:n} \carla_baz:n
\cs_set_eq:cc {carla_foo:n} {carla_baz:n}
and there's no thinking involved when the team defines them: after defining the first one in terms of primitives (\tex_let:D
, but this is irrelevant), all is needed is
\cs_generate_variant:Nn \cs_set_eq:NN { Nc, cN, cc }
that you can compare with the corresponding code in etoolbox.sty
:
\newrobustcmd{\cslet}[2]{%
\expandafter\let\csname#1\endcsname#2}
% {<cstoken>}{<csname>}
\newrobustcmd{\letcs}[2]{%
\ifcsdef{#2}
{\expandafter\let\expandafter#1\csname#2\endcsname}
{\undef#1}}
% {<csname>}{<csname>}
\newrobustcmd*{\csletcs}[2]{%
\ifcsdef{#2}
{\expandafter\let
\csname#1\expandafter\endcsname
\csname#2\endcsname}
{\csundef{#1}}}
Variants are a very nice feature of expl3
and they rely on functions having a correct signature. Look for \cs_generate_variant:Nn
on the site in order to get an idea of its usefulness.
\carlatex_if_selfexplanatory:NNnnTF
looks very self explanatory to me, compared to\carlatex@ifselfexplanatory
.