The code examples below are either from Joseph Wright or derived from code from Joseph Wright in answer to my (much) earlier question.
In standard cases, the difference is just one of how you prefer to specify the function. In the parametised case you specify the function's parameters explicitly:
\cs_new_protected_nopar:Npn \__chronos_set_minoryearformat:n #1
{
\tl_set:Nn \l__chronos_minoryearformat_tl { #1 }
\tl_replace_all:Nnn \l__chronos_minoryearformat_tl { ~ } { \c_space_token }
}
That is, the #1 tells LateX the function takes a single argument, just as \def\formatyear#1{ ... } does.
In the non-parametised case, LaTeX infers the parameters from the new function's signature:
\cs_new_protected_nopar:Nn \__chronos_set_minoryearformat:n
{
\tl_set:Nn \l__chronos_minoryearformat_tl { #1 }
\tl_replace_all:Nnn \l__chronos_minoryearformat_tl { ~ } { \c_space_token }
}
That is the n tells LaTeX the function takes a single argument, just as the 1 does in \newcommand*\formatyear[1]{ ... } or m does in \NewDocumentCommand\formatyear{m}{ ... }.
But in some cases, you want the parametised version because you want to handle the arguments passed to the function specially.
\cs_new_protected_nopar:Npn \__chronos_set_date_aux_ce:w #1 - #2 - #3 - #4 @#5 \q_stop
{
\__chronos_set_date:nnnn {#1} {#2} {#3} {#5}
}
So this function doesn't expect some mixture of tokens and braced lists of tokens. It expects something with a non-standard syntactical form.
This makes it possible to parse user input of dates which differ in how much information they provide. Basically, the user can say
date={1066-08-09}
or
date=1066
or
date={1066-03}
The package then adds to the user-specified input
<user-specified date>-01-01-0@start \q_stop
and the code will pass the appropriate information on. If the user only specified a year, a month and day will be added. If the user specified only a year and month, a day will be added. If the user specified a full date, nothing will be added except start which is used to create variable names.
This is why w. w is for 'weird'.
This is basically like similar definitions at the TeX level.
\def\mydateparser@aux#1-#2-#3-#4@#5\@nil{ ... }
would work similarly (except this isn't protected and there is no check to ensure the definition isn't obliterating some crucial thing).
\cs_new:Nnverses\cs_new:Npnwhich is covered ininterface3.pdfbut you haven't given any example or mentioned expl3, so that's just a guess. – David Carlisle Sep 29 '23 at 22:40set/gsetare not exactly different ways of defining fromnew. They're intended for redefining functions already declared withnew. So you shouldn't dosetorgsetunless you didnewor you're explicitly wanting to redefine a function declared withnewelsewhere. – cfr Sep 30 '23 at 01:29expl3functions have to have a signature. It's whether that signature is used to determine the expected parameters or whether the parameters are specified separately. – cfr Sep 30 '23 at 01:55