From a previous question, @egreg's states:
The argument types
N
andn
are the most common. The former means that the argument must be an unbraced single token, the latter means that the argument must be a braced list of tokens.
This is more or less clear to me, but it looks like the L3 interface does not enforce this for user-defined functions, here's an MWE:
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\cs_new:Nn \myFunc:N {<<#1>>}
\myFunc:N {test}
\ExplSyntaxOff
\end{document}
The code above compiles fine, even if I am passing a braced list of tokens to function myFunc:N
which is apparently declared to strictly take an unbraced single token.
This makes a big part of the L3 programming layer, i.e. function definitions and argument specifications seem like a mere syntactic convention. sigh.
Why are the argument types not enforced for user-defined functions as one would expect?
Colons
Strangely, the compiler does throw an error when I omit the colon :
, for example if I declare a function myFunc
as opposedto myFunc:N
. So that seems to be enforced...
\end
, and F3 to 'run' F4. With a single input stream, I can divide a part of it into 10 logical units, by convention, and then put all my code into the first (or 4th) unit (in the right order): result is the same. Convention allows understanding and provides process-building flexibility, like variables do in algebra.