diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3basics.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3basics.dtx | 747 |
1 files changed, 433 insertions, 314 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx index 573b39c470f..7afc9938780 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx @@ -41,7 +41,7 @@ % }^^A % } % -% \date{Released 2017/07/19} +% \date{Released 2017/09/18} % % \maketitle % @@ -1233,6 +1233,23 @@ % \cs{cs_if_exist_p:N}, and if not raises a kernel-level error. % \end{function} % +% \begin{function}{\__debug_chk_expr:nNnN} +% \begin{syntax} +% \cs{__debug_chk_expr:nNnN} \Arg{expr} \meta{eval} \Arg{convert} \meta{caller} +% \end{syntax} +% This function is only created if debugging is enabled. By default +% it is equivalent to \cs{use_i:nnnn}. When expression checking is +% enabled, it leaves in the input stream the result of \cs{tex_the:D} +% \meta{eval} \meta{expr} \cs{tex_relax:D} after checking that no +% token was left over. If any token was not taken as part of the +% expression, there is an error message displaying the result of the +% evaluation as well as the \meta{caller}. For instance \meta{eval} +% can be \cs{__int_eval:w} and \meta{caller} can be \cs{int_eval:n} or +% \cs{int_set:Nn}. The argument \meta{convert} is empty except for mu +% expressions where it is \cs{etex_mutoglue:D}, used for internal +% purposes. +% \end{function} +% % \begin{function}{\__debug_chk_var_exist:N} % \begin{syntax} % \cs{__debug_chk_var_exist:N} \meta{var} @@ -1307,7 +1324,7 @@ % \cs{cs_new:Npn} \cs{int_eval:n} |#1| \\ % ~~|{ \__int_value:w \__int_eval:w #1 \__int_eval_end: }| % \end{quote} -% replaces |#1| by |(#1)| in the definition of \cs{int_eval:n} when +% would replace |#1| by |(#1)| in the definition of \cs{int_eval:n} when % debugging is enabled. This fails if the \meta{code} contains~|##|. % The \cs{__debug_patch_conditional_args:nNNpnn} function is for use % before \cs{prg_new_conditional:Npnn} or its \texttt{_protected} @@ -1446,11 +1463,15 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[EXP]{\if_int_compare:w, \__int_to_roman:w} +% \begin{macrocode} +%<@@=int> +% \end{macrocode} +% +% \begin{macro}[EXP]{\if_int_compare:w, \@@_to_roman:w} % For integers. % \begin{macrocode} \tex_let:D \if_int_compare:w \tex_ifnum:D -\tex_let:D \__int_to_roman:w \tex_romannumeral:D +\tex_let:D \@@_to_roman:w \tex_romannumeral:D % \end{macrocode} % \end{macro} % @@ -1583,12 +1604,16 @@ % % \subsection{Selecting tokens} % -% \begin{variable}{\l__exp_internal_tl} +% \begin{macrocode} +%<@@=exp> +% \end{macrocode} +% +% \begin{variable}{\l_@@_internal_tl} % Scratch token list variable for \pkg{l3expan}, used by \cs{use:x}, % used in defining conditionals. We don't use |tl| methods because % \pkg{l3basics} is loaded earlier. % \begin{macrocode} -\cs_set_nopar:Npn \l__exp_internal_tl { } +\cs_set_nopar:Npn \l_@@_internal_tl { } % \end{macrocode} % \end{variable} % @@ -1601,12 +1626,12 @@ % % \begin{macro}{\use:x} % Fully expands its argument and passes it to the input stream. Uses -% the reserved \cs{l__exp_internal_tl} which will be set up in \pkg{l3expan}. +% the reserved \cs{l_@@_internal_tl} which will be set up in \pkg{l3expan}. % \begin{macrocode} \cs_set_protected:Npn \use:x #1 { - \cs_set_nopar:Npx \l__exp_internal_tl {#1} - \l__exp_internal_tl + \cs_set_nopar:Npx \l_@@_internal_tl {#1} + \l_@@_internal_tl } % \end{macrocode} % \end{macro} @@ -1715,7 +1740,11 @@ % % \subsection{Debugging and patching later definitions} % -% \begin{macro}[int]{\__debug:TF} +% \begin{macrocode} +%<@@=debug> +% \end{macrocode} +% +% \begin{macro}[int]{\@@:TF} % A more meaningful test of whether debugging is enabled than messing % up with guards. We can also more easily change the logic in one % place then. At present, debugging is disabled in the format and in @@ -1723,10 +1752,10 @@ % options \texttt{enable-debug}, \texttt{log-functions} or % \texttt{check-declarations} was given. % \begin{macrocode} -\cs_set_protected:Npn \__debug:TF #1#2 {#2} +\cs_set_protected:Npn \@@:TF #1#2 {#2} %<*package> \tex_ifodd:D \l@expl@enable@debug@bool - \cs_set_protected:Npn \__debug:TF #1#2 {#1} + \cs_set_protected:Npn \@@:TF #1#2 {#1} \fi: %</package> % \end{macrocode} @@ -1735,13 +1764,13 @@ % \begin{macro}{\debug_on:n, \debug_off:n} % % \begin{macrocode} -\__debug:TF +\@@:TF { \cs_set_protected:Npn \debug_on:n #1 { \exp_args:No \clist_map_inline:nn { \tl_to_str:n {#1} } { - \cs_if_exist_use:cF { __debug_##1_on: } + \cs_if_exist_use:cF { @@_##1_on: } { \__msg_kernel_error:nnn { kernel } { debug } {##1} } } } @@ -1749,7 +1778,7 @@ { \exp_args:No \clist_map_inline:nn { \tl_to_str:n {#1} } { - \cs_if_exist_use:cF { __debug_##1_off: } + \cs_if_exist_use:cF { @@_##1_off: } { \__msg_kernel_error:nnn { kernel } { debug } {##1} } } } @@ -1770,20 +1799,20 @@ % \end{macro} % % \begin{macro}[aux] -% {\__debug_check-declarations_on:, \__debug_check-declarations_off:} -% \begin{macro}[int]{\__debug_chk_var_exist:N} -% \begin{macro}[int]{\__debug_chk_cs_exist:N, \__debug_chk_cs_exist:c} -% When debugging is not active these two functions produce an -% error. Otherwise they set up \cs{__debug_chk_var_exist:N} and -% \cs{__debug_chk_cs_exist:N}, two functions that test (when +% {\@@_check-declarations_on:, \@@_check-declarations_off:} +% \begin{macro}[int]{\@@_chk_var_exist:N} +% \begin{macro}[int]{\@@_chk_cs_exist:N, \@@_chk_cs_exist:c} +% When debugging is enabled these two functions +% set up \cs{@@_chk_var_exist:N} and +% \cs{@@_chk_cs_exist:N}, two functions that test (when % \texttt{check-declarations} is active) that their argument is % defined. % \begin{macrocode} -\__debug:TF +\@@:TF { - \exp_args:Nc \cs_set_protected:Npn { __debug_check-declarations_on: } + \exp_args:Nc \cs_set_protected:Npn { @@_check-declarations_on: } { - \cs_set_protected:Npn \__debug_chk_var_exist:N ##1 + \cs_set_protected:Npn \@@_chk_var_exist:N ##1 { \cs_if_exist:NF ##1 { @@ -1791,7 +1820,7 @@ { \token_to_str:N ##1 } } } - \cs_set_protected:Npn \__debug_chk_cs_exist:N ##1 + \cs_set_protected:Npn \@@_chk_cs_exist:N ##1 { \cs_if_exist:NF ##1 { @@ -1800,17 +1829,17 @@ } } } - \exp_args:Nc \cs_set_protected:Npn { __debug_check-declarations_off: } + \exp_args:Nc \cs_set_protected:Npn { @@_check-declarations_off: } { - \cs_set_protected:Npn \__debug_chk_var_exist:N ##1 { } - \cs_set_protected:Npn \__debug_chk_cs_exist:N ##1 { } + \cs_set_protected:Npn \@@_chk_var_exist:N ##1 { } + \cs_set_protected:Npn \@@_chk_cs_exist:N ##1 { } } - \cs_set_protected:Npn \__debug_chk_cs_exist:c - { \exp_args:Nc \__debug_chk_cs_exist:N } + \cs_set_protected:Npn \@@_chk_cs_exist:c + { \exp_args:Nc \@@_chk_cs_exist:N } \tex_ifodd:D \l@expl@check@declarations@bool - \use:c { __debug_check-declarations_on: } + \use:c { @@_check-declarations_on: } \else: - \use:c { __debug_check-declarations_off: } + \use:c { @@_check-declarations_off: } \fi: } { } @@ -1819,52 +1848,110 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\__debug_log-functions_on:, \__debug_log-functions_off:} -% \begin{macro}[int]{\__debug_log:x, \__debug_suspend_log:, \__debug_resume_log:} +% \begin{macro}[aux] +% {\@@_check-expressions_on:, \@@_check-expressions_off:} +% \begin{macro}[int]{\@@_chk_expr:nNnN} +% \begin{macro}[aux]{\@@_chk_expr_aux:nNnN} +% When debugging is enabled these two functions set +% \cs{@@_chk_expr:nNnN} to test or not whether the given +% expression is valid. The idea is to evaluate the expression within +% a brace group (to catch trailing \cs{use_none:nn} or similar), then +% test that the result is what we expect. This is done by turning it +% to an integer and hitting that with \cs{tex_romannumeral:D} after +% replacing the first character by |-0|. If all goes well, that +% primitive finds a non-positive integer and gives an empty output. +% If the original expression evaluation stopped early it leaves a +% trailing \cs{tex_relax:D}, which stops the second evaluation (used +% to convert to integer) before it encounters the final +% \cs{tex_relax:D}. Since \cs{tex_romannumeral:D} does not absorb +% \cs{tex_relax:D} the output will be nonempty. Note that |#3| is +% empty except for mu expressions for which it is \cs{etex_mutoglue:D} +% to avoid an \enquote{incompatible glue units} error. Note also that +% if we had omitted the first \cs{tex_relax:D} then for instance +% |1+2\relax+3| would incorrectly be accepted as a valid integer +% expression. +% \begin{macrocode} +\@@:TF + { + \exp_args:Nc \cs_set_protected:Npn { @@_check-expressions_on: } + { + \cs_set:Npn \@@_chk_expr:nNnN ##1##2 + { + \exp_after:wN \@@_chk_expr_aux:nNnN + \exp_after:wN { \tex_the:D ##2 ##1 \tex_relax:D } + ##2 + } + } + \exp_args:Nc \cs_set_protected:Npn { @@_check-expressions_off: } + { \cs_set:Npn \@@_chk_expr:nNnN ##1##2##3##4 {##1} } + \use:c { @@_check-expressions_off: } + \cs_set:Npn \@@_chk_expr_aux:nNnN #1#2#3#4 + { + \tl_if_empty:oF + { + \tex_romannumeral:D - 0 + \exp_after:wN \use_none:n + \__int_value:w #3 #2 #1 \tex_relax:D + } + { + \__msg_kernel_expandable_error:nnnn + { kernel } { expr } {#4} {#1} + } + #1 + } + } + { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}[aux]{\@@_log-functions_on:, \@@_log-functions_off:} +% \begin{macro}[int]{\@@_log:x, \@@_suspend_log:, \@@_resume_log:} % These two functions % (corresponding to the \pkg{expl3} option \texttt{log-functions}) -% control whether \cs{__debug_log:x} writes to the log file or not. +% control whether \cs{@@_log:x} writes to the log file or not. % Since \cs{iow_log:x} does not yet have its final definition we do % not use \cs{cs_set_eq:NN} (not defined yet anyway). The -% \cs{__debug_suspend_log:} function disables \cs{__debug_log:x} until -% the matching \cs{__debug_resume_log:}. These two commands are used +% \cs{@@_suspend_log:} function disables \cs{@@_log:x} until +% the matching \cs{@@_resume_log:}. These two commands are used % to improve the logging for datatypes with multiple parts, currently % only coffins. They should come in pairs, which can be nested (this % complicates the code here and is currently unused). The function % \cs{exp_not:o} is defined in \pkg{l3expan} later on but -% \cs{__debug_suspend_log:} and \cs{__debug_resume_log:} are not used +% \cs{@@_suspend_log:} and \cs{@@_resume_log:} are not used % before that point. Once everything is defined, turn logging on or % off depending on what option was given. % When debugging is not enabled, simply produce an error. % \begin{macrocode} -\__debug:TF +\@@:TF { - \exp_args:Nc \cs_set_protected:Npn { __debug_log-functions_on: } + \exp_args:Nc \cs_set_protected:Npn { @@_log-functions_on: } { - \cs_set_protected:Npn \__debug_log:x { \iow_log:x } - \cs_set_protected:Npn \__debug_suspend_log: + \cs_set_protected:Npn \@@_log:x { \iow_log:x } + \cs_set_protected:Npn \@@_suspend_log: { - \cs_set_protected:Npx \__debug_resume_log: + \cs_set_protected:Npx \@@_resume_log: { - \cs_set_protected:Npn \__debug_resume_log: - { \exp_not:o { \__debug_resume_log: } } - \cs_set_protected:Npn \__debug_log:x - { \exp_not:o { \__debug_log:x } } + \cs_set_protected:Npn \@@_resume_log: + { \exp_not:o { \@@_resume_log: } } + \cs_set_protected:Npn \@@_log:x + { \exp_not:o { \@@_log:x } } } - \cs_set_protected:Npn \__debug_log:x { \use_none:n } + \cs_set_protected:Npn \@@_log:x { \use_none:n } } - \cs_set_protected:Npn \__debug_resume_log: { } + \cs_set_protected:Npn \@@_resume_log: { } } - \exp_args:Nc \cs_set_protected:Npn { __debug_log-functions_off: } + \exp_args:Nc \cs_set_protected:Npn { @@_log-functions_off: } { - \cs_set_protected:Npn \__debug_log:x { \use_none:n } - \cs_set_protected:Npn \__debug_suspend_log: { } - \cs_set_protected:Npn \__debug_resume_log: { } + \cs_set_protected:Npn \@@_log:x { \use_none:n } + \cs_set_protected:Npn \@@_suspend_log: { } + \cs_set_protected:Npn \@@_resume_log: { } } \tex_ifodd:D \l@expl@log@functions@bool - \use:c { __debug_log-functions_on: } + \use:c { @@_log-functions_on: } \else: - \use:c { __debug_log-functions_off: } + \use:c { @@_log-functions_off: } \fi: } { } @@ -1872,33 +1959,33 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\__debug_deprecation_on:, \__debug_deprecation_off:} -% \begin{variable}{\g__debug_deprecation_on_tl, \g__debug_deprecation_off_tl} +% \begin{macro}{\@@_deprecation_on:, \@@_deprecation_off:} +% \begin{variable}{\g_@@_deprecation_on_tl, \g_@@_deprecation_off_tl} % Some commands were more recently deprecated and not yet removed; % only make these into errors if the user requests it. This relies on % two token lists, filled up by calls to -% \cs{__debug_deprecation:nnNNpn} in each module. +% \cs{@@_deprecation:nnNNpn} in each module. % \begin{macrocode} -\__debug:TF +\@@:TF { - \cs_set_protected:Npn \__debug_deprecation_on: - { \g__debug_deprecation_on_tl } - \cs_set_protected:Npn \__debug_deprecation_off: - { \g__debug_deprecation_off_tl } - \cs_set_nopar:Npn \g__debug_deprecation_on_tl { } - \cs_set_nopar:Npn \g__debug_deprecation_off_tl { } + \cs_set_protected:Npn \@@_deprecation_on: + { \g_@@_deprecation_on_tl } + \cs_set_protected:Npn \@@_deprecation_off: + { \g_@@_deprecation_off_tl } + \cs_set_nopar:Npn \g_@@_deprecation_on_tl { } + \cs_set_nopar:Npn \g_@@_deprecation_off_tl { } } { } % \end{macrocode} % \end{variable} % \end{macro} % -% \begin{macro}[int]{\__debug_deprecation:nnNNpn} -% \begin{macro}[aux]{\__debug_deprecation_aux:nnNnn} +% \begin{macro}[int]{\@@_deprecation:nnNNpn} +% \begin{macro}[aux]{\@@_deprecation_aux:nnNnn} % Grab a definition (at present, must be \cs{cs_new_protected:Npn}). -% Add to \cs{g__debug_deprecation_on_tl} some code that makes the +% Add to \cs{g_@@_deprecation_on_tl} some code that makes the % defined macro |#3| outer (and defines it as an error). Add to -% \cs{g__debug_deprecation_off_tl} the definition itself. In both +% \cs{g_@@_deprecation_off_tl} the definition itself. In both % cases we undefine the token with \cs{tex_let:D} to avoid taking a % potentially outer macro as the argument of some \pkg{expl3} % function. Finally define the macro itself to produce a warning then @@ -1906,28 +1993,28 @@ % together with the \texttt{x}-expanding assignment and \cs{exp_not:n} % this gives a convenient way of storing the macro's definition in % itself in order to only produce the warning once for each macro. -% If debugging is disabled, \cs{__debug_deprecation:nnNNpn} lets the +% If debugging is disabled, \cs{@@_deprecation:nnNNpn} lets the % definition happen. % \begin{macrocode} -\__debug:TF +\@@:TF { - \cs_set_protected:Npn \__debug_deprecation:nnNNpn #1#2#3#4#5# + \cs_set_protected:Npn \@@_deprecation:nnNNpn #1#2#3#4#5# { \if_meaning:w \cs_new_protected:Npn #3 \else: \__msg_kernel_error:nnx { kernel } { debug-unpatchable } { \token_to_str:N #3 ~(for~deprecation) } \fi: - \__debug_deprecation_aux:nnNnn {#1} {#2} #4 {#5} + \@@_deprecation_aux:nnNnn {#1} {#2} #4 {#5} } - \cs_set_protected:Npn \__debug_deprecation_aux:nnNnn #1#2#3#4#5 + \cs_set_protected:Npn \@@_deprecation_aux:nnNnn #1#2#3#4#5 { - \tl_gput_right:Nn \g__debug_deprecation_on_tl + \tl_gput_right:Nn \g_@@_deprecation_on_tl { \tex_let:D #3 \scan_stop: \__deprecation_error:Nnn #3 {#2} {#1} } - \tl_gput_right:Nn \g__debug_deprecation_off_tl + \tl_gput_right:Nn \g_@@_deprecation_off_tl { \tex_let:D #3 \scan_stop: \cs_set_protected:Npn #3 #4 {#5} @@ -1942,50 +2029,50 @@ } } } - { \cs_set_protected:Npn \__debug_deprecation:nnNNpn #1#2 { } } + { \cs_set_protected:Npn \@@_deprecation:nnNNpn #1#2 { } } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}[int] -% {\__debug_patch:nnNNpn, \__debug_patch_conditional:nNNpnn} +% {\@@_patch:nnNNpn, \@@_patch_conditional:nNNpnn} % \begin{macro}[aux] -% {\__debug_patch_aux:nnNNnn, \__debug_patch_aux:nNNnnn} -% When debugging is not enabled, \cs{__debug_patch:nnNNpn} and -% \cs{__debug_patch_conditional:nNNpnn} throw the patch away. +% {\@@_patch_aux:nnNNnn, \@@_patch_aux:nNNnnn} +% When debugging is not enabled, \cs{@@_patch:nnNNpn} and +% \cs{@@_patch_conditional:nNNpnn} throw the patch away. % Otherwise they can be followed by \cs{cs_new:Npn} (or similar), and % \cs{prg_new_conditional:Npnn} (or similar), respectively. In each % case, grab the name of the function to be defined and its parameters % then insert tokens before and/or after the definition. % \begin{macrocode} -\__debug:TF +\@@:TF { - \cs_set_protected:Npn \__debug_patch:nnNNpn #1#2#3#4#5# - { \__debug_patch_aux:nnNNnn {#1} {#2} #3 #4 {#5} } - \cs_set_protected:Npn \__debug_patch_conditional:nNNpnn #1#2#3#4# - { \__debug_patch_aux:nNNnnn {#1} #2 #3 {#4} } - \cs_set_protected:Npn \__debug_patch_aux:nnNNnn #1#2#3#4#5#6 + \cs_set_protected:Npn \@@_patch:nnNNpn #1#2#3#4#5# + { \@@_patch_aux:nnNNnn {#1} {#2} #3 #4 {#5} } + \cs_set_protected:Npn \@@_patch_conditional:nNNpnn #1#2#3#4# + { \@@_patch_aux:nNNnnn {#1} #2 #3 {#4} } + \cs_set_protected:Npn \@@_patch_aux:nnNNnn #1#2#3#4#5#6 { #3 #4 #5 { #1 #6 #2 } } - \cs_set_protected:Npn \__debug_patch_aux:nNNnnn #1#2#3#4#5#6 + \cs_set_protected:Npn \@@_patch_aux:nNNnnn #1#2#3#4#5#6 { #2 #3 #4 {#5} { #1 #6 } } } { - \cs_set_protected:Npn \__debug_patch:nnNNpn #1#2 { } - \cs_set_protected:Npn \__debug_patch_conditional:nNNpnn #1 { } + \cs_set_protected:Npn \@@_patch:nnNNpn #1#2 { } + \cs_set_protected:Npn \@@_patch_conditional:nNNpnn #1 { } } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}[int] -% {\__debug_patch_args:nNNpn, \__debug_patch_conditional_args:nNNpnn} +% {\@@_patch_args:nNNpn, \@@_patch_conditional_args:nNNpnn} % \begin{macro}[aux] % { -% \__debug_tmp:w, -% \__debug_patch_args_aux:nNNnn, -% \__debug_patch_args_aux:nNNnnn +% \@@_tmp:w, +% \@@_patch_args_aux:nNNnn, +% \@@_patch_args_aux:nNNnnn % } -% See \cs{__debug_patch:nnNNpn}. The first argument is something like +% See \cs{@@_patch:nnNNpn}. The first argument is something like % |{#1}{(#2)}|. Define a temporary macro using the \meta{parameters} % and \meta{code} of the definition that follows, then expand that % temporary macro in front of the first argument to obtain new @@ -1993,28 +2080,28 @@ % was directly typed in the file. To make it easy to expand in the % definition, treat it as a \enquote{pre}-code to an empty definition. % \begin{macrocode} -\__debug:TF +\@@:TF { - \cs_set_protected:Npn \__debug_patch_args:nNNpn #1#2#3#4# - { \__debug_patch_args_aux:nNNnn {#1} #2 #3 {#4} } - \cs_set_protected:Npn \__debug_patch_conditional_args:nNNpnn #1#2#3#4# - { \__debug_patch_args_aux:nNNnnn {#1} #2 #3 {#4} } - \cs_set_protected:Npn \__debug_patch_args_aux:nNNnn #1#2#3#4#5 + \cs_set_protected:Npn \@@_patch_args:nNNpn #1#2#3#4# + { \@@_patch_args_aux:nNNnn {#1} #2 #3 {#4} } + \cs_set_protected:Npn \@@_patch_conditional_args:nNNpnn #1#2#3#4# + { \@@_patch_args_aux:nNNnnn {#1} #2 #3 {#4} } + \cs_set_protected:Npn \@@_patch_args_aux:nNNnn #1#2#3#4#5 { - \cs_set:Npn \__debug_tmp:w #4 {#5} - \exp_after:wN \__debug_patch_aux:nnNNnn \exp_after:wN - { \__debug_tmp:w #1 } { } #2 #3 {#4} { } + \cs_set:Npn \@@_tmp:w #4 {#5} + \exp_after:wN \@@_patch_aux:nnNNnn \exp_after:wN + { \@@_tmp:w #1 } { } #2 #3 {#4} { } } - \cs_set_protected:Npn \__debug_patch_args_aux:nNNnnn #1#2#3#4#5#6 + \cs_set_protected:Npn \@@_patch_args_aux:nNNnnn #1#2#3#4#5#6 { - \cs_set:Npn \__debug_tmp:w #4 {#6} - \exp_after:wN \__debug_patch_aux:nNNnnn \exp_after:wN - { \__debug_tmp:w #1 } #2 #3 {#4} {#5} { } + \cs_set:Npn \@@_tmp:w #4 {#6} + \exp_after:wN \@@_patch_aux:nNNnnn \exp_after:wN + { \@@_tmp:w #1 } #2 #3 {#4} {#5} { } } } { - \cs_set_protected:Npn \__debug_patch_args:nNNpn #1 { } - \cs_set_protected:Npn \__debug_patch_conditional_args:nNNpnn #1 { } + \cs_set_protected:Npn \@@_patch_args:nNNpn #1 { } + \cs_set_protected:Npn \@@_patch_conditional_args:nNNpnn #1 { } } % \end{macrocode} % \end{macro} @@ -2022,6 +2109,10 @@ % % \subsection{Conditional processing and definitions} % +% \begin{macrocode} +%<@@=prg> +% \end{macrocode} +% % Underneath any predicate function (|_p|) or other conditional forms % (|TF|, etc.) is a built-in logic saying that it after all of the % testing and processing must return the \meta{state} this leaves @@ -2070,7 +2161,7 @@ % \prg_set_protected_conditional:Npnn , % \prg_new_protected_conditional:Npnn , % } -% \begin{macro}[aux]{\__prg_generate_conditional_parm:nnNpnn} +% \begin{macro}[aux]{\@@_generate_conditional_parm:nnNpnn} % The user functions for the types using parameter text from the % programmer. The various functions only differ by which function is % used for the assignment. For those |Npnn| type functions, we must @@ -2082,16 +2173,16 @@ % conditionals. % \begin{macrocode} \cs_set_protected:Npn \prg_set_conditional:Npnn - { \__prg_generate_conditional_parm:nnNpnn { set } { } } + { \@@_generate_conditional_parm:nnNpnn { set } { } } \cs_set_protected:Npn \prg_new_conditional:Npnn - { \__prg_generate_conditional_parm:nnNpnn { new } { } } + { \@@_generate_conditional_parm:nnNpnn { new } { } } \cs_set_protected:Npn \prg_set_protected_conditional:Npnn - { \__prg_generate_conditional_parm:nnNpnn { set } { _protected } } + { \@@_generate_conditional_parm:nnNpnn { set } { _protected } } \cs_set_protected:Npn \prg_new_protected_conditional:Npnn - { \__prg_generate_conditional_parm:nnNpnn { new } { _protected } } -\cs_set_protected:Npn \__prg_generate_conditional_parm:nnNpnn #1#2#3#4# + { \@@_generate_conditional_parm:nnNpnn { new } { _protected } } +\cs_set_protected:Npn \@@_generate_conditional_parm:nnNpnn #1#2#3#4# { - \__cs_split_function:NN #3 \__prg_generate_conditional:nnNnnnnn + \__cs_split_function:NN #3 \@@_generate_conditional:nnNnnnnn {#1} {#2} {#4} } % \end{macrocode} @@ -2107,8 +2198,8 @@ % } % \begin{macro}[aux] % { -% \__prg_generate_conditional_count:nnNnn , -% \__prg_generate_conditional_count:nnNnnnn +% \@@_generate_conditional_count:nnNnn , +% \@@_generate_conditional_count:nnNnnnn % } % The user functions for the types automatically inserting the correct % parameter text based on the signature. The various functions only @@ -2124,22 +2215,22 @@ % later. % \begin{macrocode} \cs_set_protected:Npn \prg_set_conditional:Nnn - { \__prg_generate_conditional_count:nnNnn { set } { } } + { \@@_generate_conditional_count:nnNnn { set } { } } \cs_set_protected:Npn \prg_new_conditional:Nnn - { \__prg_generate_conditional_count:nnNnn { new } { } } + { \@@_generate_conditional_count:nnNnn { new } { } } \cs_set_protected:Npn \prg_set_protected_conditional:Nnn - { \__prg_generate_conditional_count:nnNnn { set } { _protected } } + { \@@_generate_conditional_count:nnNnn { set } { _protected } } \cs_set_protected:Npn \prg_new_protected_conditional:Nnn - { \__prg_generate_conditional_count:nnNnn { new } { _protected } } -\cs_set_protected:Npn \__prg_generate_conditional_count:nnNnn #1#2#3 + { \@@_generate_conditional_count:nnNnn { new } { _protected } } +\cs_set_protected:Npn \@@_generate_conditional_count:nnNnn #1#2#3 { - \__cs_split_function:NN #3 \__prg_generate_conditional_count:nnNnnnn + \__cs_split_function:NN #3 \@@_generate_conditional_count:nnNnnnn {#1} {#2} } -\cs_set_protected:Npn \__prg_generate_conditional_count:nnNnnnn #1#2#3#4#5 +\cs_set_protected:Npn \@@_generate_conditional_count:nnNnnnn #1#2#3#4#5 { \__cs_parm_from_arg_count:nnF - { \__prg_generate_conditional:nnNnnnnn {#1} {#2} #3 {#4} {#5} } + { \@@_generate_conditional:nnNnnnnn {#1} {#2} #3 {#4} {#5} } { \tl_count:n {#2} } { \__msg_kernel_error:nnxx { kernel } { bad-number-of-arguments } @@ -2154,8 +2245,8 @@ % % \begin{macro}[aux] % { -% \__prg_generate_conditional:nnNnnnnn, -% \__prg_generate_conditional:nnnnnnw +% \@@_generate_conditional:nnNnnnnn, +% \@@_generate_conditional:nnnnnnw % } % The workhorse here is going through a list of desired forms, \emph{i.e.}, % |p|, |TF|, |T| and |F|. The first three arguments come from splitting up @@ -2168,7 +2259,7 @@ % replacement text which we will augment when defining the forms. % The use of \cs{tl_to_str:n} makes the later loop more robust. % \begin{macrocode} -\cs_set_protected:Npn \__prg_generate_conditional:nnNnnnnn #1#2#3#4#5#6#7#8 +\cs_set_protected:Npn \@@_generate_conditional:nnNnnnnn #1#2#3#4#5#6#7#8 { \if_meaning:w \c_false_bool #3 \__msg_kernel_error:nnx { kernel } { missing-colon } @@ -2177,7 +2268,7 @@ \fi: \use:x { - \exp_not:N \__prg_generate_conditional:nnnnnnw + \exp_not:N \@@_generate_conditional:nnnnnnw \exp_not:n { {#4} {#5} {#1} {#2} {#6} {#8} } \tl_to_str:n {#7} \exp_not:n { , \q_recursion_tail , \q_recursion_stop } @@ -2192,12 +2283,12 @@ % then \cs{use_none:nnnnnnn} cleans up. Otherwise, the % error message is removed by the variant form. % \begin{macrocode} -\cs_set_protected:Npn \__prg_generate_conditional:nnnnnnw #1#2#3#4#5#6#7 , +\cs_set_protected:Npn \@@_generate_conditional:nnnnnnw #1#2#3#4#5#6#7 , { \if_meaning:w \q_recursion_tail #7 \exp_after:wN \use_none_delimit_by_q_recursion_stop:w \fi: - \use:c { __prg_generate_ #7 _form:wnnnnnn } + \use:c { @@_generate_ #7 _form:wnnnnnn } \tl_if_empty:nF {#7} { \__msg_kernel_error:nnxx @@ -2207,17 +2298,17 @@ \use_none:nnnnnnn \q_stop {#1} {#2} {#3} {#4} {#5} {#6} - \__prg_generate_conditional:nnnnnnw {#1} {#2} {#3} {#4} {#5} {#6} + \@@_generate_conditional:nnnnnnw {#1} {#2} {#3} {#4} {#5} {#6} } % \end{macrocode} % \end{macro} % % \begin{macro}[aux] % { -% \__prg_generate_p_form:wnnnnnn, -% \__prg_generate_TF_form:wnnnnnn, -% \__prg_generate_T_form:wnnnnnn, -% \__prg_generate_F_form:wnnnnnn +% \@@_generate_p_form:wnnnnnn, +% \@@_generate_TF_form:wnnnnnn, +% \@@_generate_T_form:wnnnnnn, +% \@@_generate_F_form:wnnnnnn % } % How to generate the various forms. Those functions take the % following arguments: 1: \texttt{set} or \texttt{new}, 2: empty or @@ -2229,7 +2320,7 @@ % version. The |p| form is only valid for expandable tests, we check % for that by making sure that the second argument is empty. % \begin{macrocode} -\cs_set_protected:Npn \__prg_generate_p_form:wnnnnnn +\cs_set_protected:Npn \@@_generate_p_form:wnnnnnn #1 \q_stop #2#3#4#5#6#7 { \if_meaning:w \scan_stop: #3 \scan_stop: @@ -2246,19 +2337,19 @@ { \token_to_str:c { #4 _p: #5 } } } } -\cs_set_protected:Npn \__prg_generate_T_form:wnnnnnn +\cs_set_protected:Npn \@@_generate_T_form:wnnnnnn #1 \q_stop #2#3#4#5#6#7 { \exp_args:cc { cs_ #2 #3 :Npn } { #4 : #5 T } #6 { #7 \exp_end: \use:n \use_none:n } } -\cs_set_protected:Npn \__prg_generate_F_form:wnnnnnn +\cs_set_protected:Npn \@@_generate_F_form:wnnnnnn #1 \q_stop #2#3#4#5#6#7 { \exp_args:cc { cs_ #2 #3 :Npn } { #4 : #5 F } #6 { #7 \exp_end: { } } } -\cs_set_protected:Npn \__prg_generate_TF_form:wnnnnnn +\cs_set_protected:Npn \@@_generate_TF_form:wnnnnnn #1 \q_stop #2#3#4#5#6#7 { \exp_args:cc { cs_ #2 #3 :Npn } { #4 : #5 TF } #6 @@ -2268,7 +2359,7 @@ % \end{macro} % % \begin{macro}{\prg_set_eq_conditional:NNn, \prg_new_eq_conditional:NNn} -% \begin{macro}[aux]{\__prg_set_eq_conditional:NNNn} +% \begin{macro}[aux]{\@@_set_eq_conditional:NNNn} % The setting-equal functions. Split both functions and feed % \Arg{name_1} \Arg{signature_1} \meta{boolean_1} % \Arg{name_2} \Arg{signature_2} \meta{boolean_2} @@ -2277,14 +2368,14 @@ % to a first auxiliary. % \begin{macrocode} \cs_set_protected:Npn \prg_set_eq_conditional:NNn - { \__prg_set_eq_conditional:NNNn \cs_set_eq:cc } + { \@@_set_eq_conditional:NNNn \cs_set_eq:cc } \cs_set_protected:Npn \prg_new_eq_conditional:NNn - { \__prg_set_eq_conditional:NNNn \cs_new_eq:cc } -\cs_set_protected:Npn \__prg_set_eq_conditional:NNNn #1#2#3#4 + { \@@_set_eq_conditional:NNNn \cs_new_eq:cc } +\cs_set_protected:Npn \@@_set_eq_conditional:NNNn #1#2#3#4 { \use:x { - \exp_not:N \__prg_set_eq_conditional:nnNnnNNw + \exp_not:N \@@_set_eq_conditional:nnNnnNNw \__cs_split_function:NN #2 \prg_do_nothing: \__cs_split_function:NN #3 \prg_do_nothing: \exp_not:N #1 @@ -2298,15 +2389,15 @@ % % \begin{macro}[aux] % { -% \__prg_set_eq_conditional:nnNnnNNw , -% \__prg_set_eq_conditional_loop:nnnnNw +% \@@_set_eq_conditional:nnNnnNNw , +% \@@_set_eq_conditional_loop:nnnnNw % } % \begin{macro}[aux, EXP] % { -% \__prg_set_eq_conditional_p_form:nnn , -% \__prg_set_eq_conditional_TF_form:nnn , -% \__prg_set_eq_conditional_T_form:nnn , -% \__prg_set_eq_conditional_F_form:nnn , +% \@@_set_eq_conditional_p_form:nnn , +% \@@_set_eq_conditional_TF_form:nnn , +% \@@_set_eq_conditional_T_form:nnn , +% \@@_set_eq_conditional_F_form:nnn , % } % Split the function to be defined, and setup a manual clist loop over % argument |#6| of the first auxiliary. The second auxiliary receives @@ -2319,7 +2410,7 @@ % step in the loop, make sure that the conditional form we copy is % defined, and copy it, otherwise abort. % \begin{macrocode} -\cs_set_protected:Npn \__prg_set_eq_conditional:nnNnnNNw #1#2#3#4#5#6 +\cs_set_protected:Npn \@@_set_eq_conditional:nnNnnNNw #1#2#3#4#5#6 { \if_meaning:w \c_false_bool #3 \__msg_kernel_error:nnx { kernel } { missing-colon } @@ -2331,14 +2422,14 @@ { \token_to_str:c {#4} } \exp_after:wN \use_none_delimit_by_q_recursion_stop:w \fi: - \__prg_set_eq_conditional_loop:nnnnNw {#1} {#2} {#4} {#5} + \@@_set_eq_conditional_loop:nnnnNw {#1} {#2} {#4} {#5} } -\cs_set_protected:Npn \__prg_set_eq_conditional_loop:nnnnNw #1#2#3#4#5#6 , +\cs_set_protected:Npn \@@_set_eq_conditional_loop:nnnnNw #1#2#3#4#5#6 , { \if_meaning:w \q_recursion_tail #6 \exp_after:wN \use_none_delimit_by_q_recursion_stop:w \fi: - \use:c { __prg_set_eq_conditional_ #6 _form:wNnnnn } + \use:c { @@_set_eq_conditional_ #6 _form:wNnnnn } \tl_if_empty:nF {#6} { \__msg_kernel_error:nnxx @@ -2348,23 +2439,23 @@ \use_none:nnnnnn \q_stop #5 {#1} {#2} {#3} {#4} - \__prg_set_eq_conditional_loop:nnnnNw {#1} {#2} {#3} {#4} #5 + \@@_set_eq_conditional_loop:nnnnNw {#1} {#2} {#3} {#4} #5 } \__debug_patch:nnNNpn { \__debug_chk_cs_exist:c { #5 _p : #6 } } { } -\cs_set:Npn \__prg_set_eq_conditional_p_form:wNnnnn #1 \q_stop #2#3#4#5#6 +\cs_set:Npn \@@_set_eq_conditional_p_form:wNnnnn #1 \q_stop #2#3#4#5#6 { #2 { #3 _p : #4 } { #5 _p : #6 } } \__debug_patch:nnNNpn { \__debug_chk_cs_exist:c { #5 : #6 TF } } { } -\cs_set:Npn \__prg_set_eq_conditional_TF_form:wNnnnn #1 \q_stop #2#3#4#5#6 +\cs_set:Npn \@@_set_eq_conditional_TF_form:wNnnnn #1 \q_stop #2#3#4#5#6 { #2 { #3 : #4 TF } { #5 : #6 TF } } \__debug_patch:nnNNpn { \__debug_chk_cs_exist:c { #5 : #6 T } } { } -\cs_set:Npn \__prg_set_eq_conditional_T_form:wNnnnn #1 \q_stop #2#3#4#5#6 +\cs_set:Npn \@@_set_eq_conditional_T_form:wNnnnn #1 \q_stop #2#3#4#5#6 { #2 { #3 : #4 T } { #5 : #6 T } } \__debug_patch:nnNNpn { \__debug_chk_cs_exist:c { #5 : #6 F } } { } -\cs_set:Npn \__prg_set_eq_conditional_F_form:wNnnnn #1 \q_stop #2#3#4#5#6 +\cs_set:Npn \@@_set_eq_conditional_F_form:wNnnnn #1 \q_stop #2#3#4#5#6 { #2 { #3 : #4 F } { #5 : #6 F } } % \end{macrocode} % \end{macro} @@ -2389,8 +2480,12 @@ % % \subsection{Dissecting a control sequence} % +% \begin{macrocode} +%<@@=cs> +% \end{macrocode} +% % \begin{macro}[EXP]{\cs_to_str:N} -% \begin{macro}[aux, EXP]{\__cs_to_str:N, \__cs_to_str:w} +% \begin{macro}[aux, EXP]{\@@_to_str:N, \@@_to_str:w} % This converts a control sequence into the character string of its % name, removing the leading escape character. This turns out to be % a non-trivial matter as there a different cases: @@ -2411,17 +2506,17 @@ % a little more intricate still. When the escape character is printable, % \verb*|\token_to_str:N \ | yields the escape character itself and a space. % The character codes are different, thus the \cs{if:w} test is false, -% and \TeX{} reads \cs{__cs_to_str:N} after turning the following +% and \TeX{} reads \cs{@@_to_str:N} after turning the following % control sequence into a string; this auxiliary removes the escape % character, and stops the expansion of the initial \cs{tex_romannumeral:D}. % The second case is that the escape character is not printable. Then % the \cs{if:w} test is unfinished after reading a the space from -% \verb*|\token_to_str:N \ |, and the auxiliary \cs{__cs_to_str:w} +% \verb*|\token_to_str:N \ |, and the auxiliary \cs{@@_to_str:w} % is expanded, feeding |-| as a second character for the test; % the test is false, and \TeX{} skips to \cs{fi:}, then performs % \cs{token_to_str:N}, and stops the \cs{tex_romannumeral:D} with \cs{c_zero}. % The last case is that the escape character is itself a space. In this -% case, the \cs{if:w} test is true, and the auxiliary \cs{__cs_to_str:w} +% case, the \cs{if:w} test is true, and the auxiliary \cs{@@_to_str:w} % comes into play, inserting |-\__int_value:w|, which expands \cs{c_zero} % to the character |0|. The initial \cs{tex_romannumeral:D} then sees % |0|, which is not a terminated number, followed by the escape character, @@ -2440,11 +2535,11 @@ % we make this dependency explicit. % \begin{macrocode} \tex_romannumeral:D - \if:w \token_to_str:N \ \__cs_to_str:w \fi: - \exp_after:wN \__cs_to_str:N \token_to_str:N + \if:w \token_to_str:N \ \@@_to_str:w \fi: + \exp_after:wN \@@_to_str:N \token_to_str:N } -\cs_set:Npn \__cs_to_str:N #1 { \c_zero } -\cs_set:Npn \__cs_to_str:w #1 \__cs_to_str:N +\cs_set:Npn \@@_to_str:N #1 { \c_zero } +\cs_set:Npn \@@_to_str:w #1 \@@_to_str:N { - \__int_value:w \fi: \exp_after:wN \c_zero } % \end{macrocode} % If speed is a concern we could use \tn{csstring} in \LuaTeX{}. For @@ -2454,18 +2549,18 @@ % \end{macro} % \end{macro} % -% \begin{macro}[EXP, int]{\__cs_split_function:NN} +% \begin{macro}[EXP, int]{\@@_split_function:NN} % \begin{macro}[aux, EXP] -% {\__cs_split_function_auxi:w, \__cs_split_function_auxii:w} +% {\@@_split_function_auxi:w, \@@_split_function_auxii:w} % This function takes a function name and splits it into name with % the escape char removed and argument specification. In addition to % this, a third argument, a boolean \meta{true} or \meta{false} is % returned with \meta{true} for when there is a colon in the function % and \meta{false} if there is not. Lastly, the second argument of -% \cs{__cs_split_function:NN} is supposed to be a function +% \cs{@@_split_function:NN} is supposed to be a function % taking three variables, one for name, one for signature, and one % for the boolean. For example, -% |\__cs_split_function:NN \foo_bar:cnx \use_i:nnn| as input +% |\@@_split_function:NN \foo_bar:cnx \use_i:nnn| as input % becomes |\use_i:nnn {foo_bar} {cnx} \c_true_bool|. % % We cannot use |:| directly as it has the wrong category code so @@ -2482,34 +2577,34 @@ % auxiliary trims the trailing \cs{q_mark} from the function name if % present (that is, if the original function had no colon). % \begin{macrocode} -\cs_set:Npx \__cs_split_function:NN #1 +\cs_set:Npx \@@_split_function:NN #1 { \exp_not:N \exp_after:wN \exp_not:N \exp_after:wN - \exp_not:N \exp_after:wN \exp_not:N \__cs_split_function_auxi:w + \exp_not:N \exp_after:wN \exp_not:N \@@_split_function_auxi:w \exp_not:N \cs_to_str:N #1 \exp_not:N \q_mark \c_true_bool \token_to_str:N : \exp_not:N \q_mark \c_false_bool \exp_not:N \q_stop } \use:x { - \cs_set:Npn \exp_not:N \__cs_split_function_auxi:w + \cs_set:Npn \exp_not:N \@@_split_function_auxi:w ##1 \token_to_str:N : ##2 \exp_not:N \q_mark ##3##4 \exp_not:N \q_stop ##5 } - { \__cs_split_function_auxii:w #5 #1 \q_mark \q_stop {#2} #3 } -\cs_set:Npn \__cs_split_function_auxii:w #1#2 \q_mark #3 \q_stop + { \@@_split_function_auxii:w #5 #1 \q_mark \q_stop {#2} #3 } +\cs_set:Npn \@@_split_function_auxii:w #1#2 \q_mark #3 \q_stop { #1 {#2} } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}[EXP, int] -% {\__cs_get_function_name:N, \__cs_get_function_signature:N} +% {\@@_get_function_name:N, \@@_get_function_signature:N} % Simple wrappers. % \begin{macrocode} -\cs_set:Npn \__cs_get_function_name:N #1 - { \__cs_split_function:NN #1 \use_i:nnn } -\cs_set:Npn \__cs_get_function_signature:N #1 - { \__cs_split_function:NN #1 \use_ii:nnn } +\cs_set:Npn \@@_get_function_name:N #1 + { \@@_split_function:NN #1 \use_i:nnn } +\cs_set:Npn \@@_get_function_signature:N #1 + { \@@_split_function:NN #1 \use_ii:nnn } % \end{macrocode} % \end{macro} % @@ -2715,6 +2810,10 @@ % % \subsection{Defining new functions} % +% \begin{macrocode} +%<@@=cs> +% \end{macrocode} +% % \begin{macro} % { % \cs_new_nopar:Npn , \cs_new_nopar:Npx , @@ -2722,11 +2821,11 @@ % \cs_new_protected_nopar:Npn , \cs_new_protected_nopar:Npx , % \cs_new_protected:Npn , \cs_new_protected:Npx % } -% \begin{macro}[int]{\__cs_tmp:w} +% \begin{macro}[int]{\@@_tmp:w} % Function which check that the control sequence is free before % defining it. % \begin{macrocode} -\cs_set:Npn \__cs_tmp:w #1#2 +\cs_set:Npn \@@_tmp:w #1#2 { \cs_set_protected:Npn #1 ##1 { @@ -2734,14 +2833,14 @@ #2 ##1 } } -\__cs_tmp:w \cs_new_nopar:Npn \cs_gset_nopar:Npn -\__cs_tmp:w \cs_new_nopar:Npx \cs_gset_nopar:Npx -\__cs_tmp:w \cs_new:Npn \cs_gset:Npn -\__cs_tmp:w \cs_new:Npx \cs_gset:Npx -\__cs_tmp:w \cs_new_protected_nopar:Npn \cs_gset_protected_nopar:Npn -\__cs_tmp:w \cs_new_protected_nopar:Npx \cs_gset_protected_nopar:Npx -\__cs_tmp:w \cs_new_protected:Npn \cs_gset_protected:Npn -\__cs_tmp:w \cs_new_protected:Npx \cs_gset_protected:Npx +\@@_tmp:w \cs_new_nopar:Npn \cs_gset_nopar:Npn +\@@_tmp:w \cs_new_nopar:Npx \cs_gset_nopar:Npx +\@@_tmp:w \cs_new:Npn \cs_gset:Npn +\@@_tmp:w \cs_new:Npx \cs_gset:Npx +\@@_tmp:w \cs_new_protected_nopar:Npn \cs_gset_protected_nopar:Npn +\@@_tmp:w \cs_new_protected_nopar:Npx \cs_gset_protected_nopar:Npx +\@@_tmp:w \cs_new_protected:Npn \cs_gset_protected:Npn +\@@_tmp:w \cs_new_protected:Npx \cs_gset_protected:Npx % \end{macrocode} % \end{macro} % \end{macro} @@ -2763,14 +2862,14 @@ % \cs{cs_set_nopar:Npn}. This means that there might be a parameter % string between the two arguments. % \begin{macrocode} -\cs_set:Npn \__cs_tmp:w #1#2 +\cs_set:Npn \@@_tmp:w #1#2 { \cs_new_protected_nopar:Npn #1 { \exp_args:Nc #2 } } -\__cs_tmp:w \cs_set_nopar:cpn \cs_set_nopar:Npn -\__cs_tmp:w \cs_set_nopar:cpx \cs_set_nopar:Npx -\__cs_tmp:w \cs_gset_nopar:cpn \cs_gset_nopar:Npn -\__cs_tmp:w \cs_gset_nopar:cpx \cs_gset_nopar:Npx -\__cs_tmp:w \cs_new_nopar:cpn \cs_new_nopar:Npn -\__cs_tmp:w \cs_new_nopar:cpx \cs_new_nopar:Npx +\@@_tmp:w \cs_set_nopar:cpn \cs_set_nopar:Npn +\@@_tmp:w \cs_set_nopar:cpx \cs_set_nopar:Npx +\@@_tmp:w \cs_gset_nopar:cpn \cs_gset_nopar:Npn +\@@_tmp:w \cs_gset_nopar:cpx \cs_gset_nopar:Npx +\@@_tmp:w \cs_new_nopar:cpn \cs_new_nopar:Npn +\@@_tmp:w \cs_new_nopar:cpx \cs_new_nopar:Npx % \end{macrocode} % \end{macro} % @@ -2783,12 +2882,12 @@ % Variants of the \cs{cs_set:Npn} versions which make a csname out % of the first arguments. We may also do this globally. % \begin{macrocode} -\__cs_tmp:w \cs_set:cpn \cs_set:Npn -\__cs_tmp:w \cs_set:cpx \cs_set:Npx -\__cs_tmp:w \cs_gset:cpn \cs_gset:Npn -\__cs_tmp:w \cs_gset:cpx \cs_gset:Npx -\__cs_tmp:w \cs_new:cpn \cs_new:Npn -\__cs_tmp:w \cs_new:cpx \cs_new:Npx +\@@_tmp:w \cs_set:cpn \cs_set:Npn +\@@_tmp:w \cs_set:cpx \cs_set:Npx +\@@_tmp:w \cs_gset:cpn \cs_gset:Npn +\@@_tmp:w \cs_gset:cpx \cs_gset:Npx +\@@_tmp:w \cs_new:cpn \cs_new:Npn +\@@_tmp:w \cs_new:cpx \cs_new:Npx % \end{macrocode} % \end{macro} % @@ -2801,12 +2900,12 @@ % Variants of the \cs{cs_set_protected_nopar:Npn} versions which make % a csname out of the first arguments. We may also do this globally. % \begin{macrocode} -\__cs_tmp:w \cs_set_protected_nopar:cpn \cs_set_protected_nopar:Npn -\__cs_tmp:w \cs_set_protected_nopar:cpx \cs_set_protected_nopar:Npx -\__cs_tmp:w \cs_gset_protected_nopar:cpn \cs_gset_protected_nopar:Npn -\__cs_tmp:w \cs_gset_protected_nopar:cpx \cs_gset_protected_nopar:Npx -\__cs_tmp:w \cs_new_protected_nopar:cpn \cs_new_protected_nopar:Npn -\__cs_tmp:w \cs_new_protected_nopar:cpx \cs_new_protected_nopar:Npx +\@@_tmp:w \cs_set_protected_nopar:cpn \cs_set_protected_nopar:Npn +\@@_tmp:w \cs_set_protected_nopar:cpx \cs_set_protected_nopar:Npx +\@@_tmp:w \cs_gset_protected_nopar:cpn \cs_gset_protected_nopar:Npn +\@@_tmp:w \cs_gset_protected_nopar:cpx \cs_gset_protected_nopar:Npx +\@@_tmp:w \cs_new_protected_nopar:cpn \cs_new_protected_nopar:Npn +\@@_tmp:w \cs_new_protected_nopar:cpx \cs_new_protected_nopar:Npx % \end{macrocode} % \end{macro} % @@ -2819,12 +2918,12 @@ % Variants of the \cs{cs_set_protected:Npn} versions which make a csname % out of the first arguments. We may also do this globally. % \begin{macrocode} -\__cs_tmp:w \cs_set_protected:cpn \cs_set_protected:Npn -\__cs_tmp:w \cs_set_protected:cpx \cs_set_protected:Npx -\__cs_tmp:w \cs_gset_protected:cpn \cs_gset_protected:Npn -\__cs_tmp:w \cs_gset_protected:cpx \cs_gset_protected:Npx -\__cs_tmp:w \cs_new_protected:cpn \cs_new_protected:Npn -\__cs_tmp:w \cs_new_protected:cpx \cs_new_protected:Npx +\@@_tmp:w \cs_set_protected:cpn \cs_set_protected:Npn +\@@_tmp:w \cs_set_protected:cpx \cs_set_protected:Npx +\@@_tmp:w \cs_gset_protected:cpn \cs_gset_protected:Npn +\@@_tmp:w \cs_gset_protected:cpx \cs_gset_protected:Npx +\@@_tmp:w \cs_new_protected:cpn \cs_new_protected:Npn +\@@_tmp:w \cs_new_protected:cpx \cs_new_protected:Npx % \end{macrocode} % \end{macro} % @@ -2893,8 +2992,12 @@ % % \subsection{Generating parameter text from argument count} % -% \begin{macro}[int]{\__cs_parm_from_arg_count:nnF} -% \begin{macro}[aux]{\__cs_parm_from_arg_count_test:nnF} +% \begin{macrocode} +%<@@=cs> +% \end{macrocode} +% +% \begin{macro}[int]{\@@_parm_from_arg_count:nnF} +% \begin{macro}[aux]{\@@_parm_from_arg_count_test:nnF} % \LaTeX3 provides shorthands to define control sequences and % conditionals with a simple parameter text, derived directly from the % signature, or more generally from knowing the number of arguments, @@ -2907,9 +3010,9 @@ % the functions use here are not defined yet, but will be defined % before this function is called. % \begin{macrocode} -\cs_set_protected:Npn \__cs_parm_from_arg_count:nnF #1#2 +\cs_set_protected:Npn \@@_parm_from_arg_count:nnF #1#2 { - \exp_args:Nx \__cs_parm_from_arg_count_test:nnF + \exp_args:Nx \@@_parm_from_arg_count_test:nnF { \exp_after:wN \exp_not:n \if_case:w \__int_eval:w (#2) \__int_eval_end: @@ -2928,7 +3031,7 @@ } {#1} } -\cs_set_protected:Npn \__cs_parm_from_arg_count_test:nnF #1#2 +\cs_set_protected:Npn \@@_parm_from_arg_count_test:nnF #1#2 { \if_meaning:w \c_false_bool #1 \exp_after:wN \use_ii:nn @@ -2943,17 +3046,21 @@ % % \subsection{Defining functions from a given number of arguments} % -% \begin{macro}[EXP, int]{\__cs_count_signature:N, \__cs_count_signature:c} -% \begin{macro}[aux, EXP]{\__cs_count_signature:nnN} +% \begin{macrocode} +%<@@=cs> +% \end{macrocode} +% +% \begin{macro}[EXP, int]{\@@_count_signature:N, \@@_count_signature:c} +% \begin{macro}[aux, EXP]{\@@_count_signature:nnN} % Counting the number of tokens in the signature, \emph{i.e.}, the % number of arguments the function should take. Since this is not % used in any time-critical function, we simply use \cs{tl_count:n} if % there is a signature, otherwise $-1$ arguments to signal an error. % We need a variant form right away. % \begin{macrocode} -\cs_new:Npn \__cs_count_signature:N #1 - { \int_eval:n { \__cs_split_function:NN #1 \__cs_count_signature:nnN } } -\cs_new:Npn \__cs_count_signature:nnN #1#2#3 +\cs_new:Npn \@@_count_signature:N #1 + { \int_eval:n { \@@_split_function:NN #1 \@@_count_signature:nnN } } +\cs_new:Npn \@@_count_signature:nnN #1#2#3 { \if_meaning:w \c_true_bool #3 \tl_count:n {#2} @@ -2961,8 +3068,8 @@ -1 \fi: } -\cs_new:Npn \__cs_count_signature:c - { \exp_args:Nc \__cs_count_signature:N } +\cs_new:Npn \@@_count_signature:c + { \exp_args:Nc \@@_count_signature:N } % \end{macrocode} % \end{macro} % \end{macro} @@ -2986,7 +3093,7 @@ % \begin{macrocode} \cs_new_protected:Npn \cs_generate_from_arg_count:NNnn #1#2#3#4 { - \__cs_parm_from_arg_count:nnF { \use:nnn #2 #1 } {#3} + \@@_parm_from_arg_count:nnF { \use:nnn #2 #1 } {#3} { \__msg_kernel_error:nnxx { kernel } { bad-number-of-arguments } { \token_to_str:N #1 } { \int_eval:n {#3} } @@ -3007,6 +3114,10 @@ % % \subsection{Using the signature to define functions} % +% \begin{macrocode} +%<@@=cs> +% \end{macrocode} +% % We can now combine some of the tools we have to provide a simple % interface for defining functions, where the number of arguments is % read from the signature. For instance, @@ -3040,25 +3151,25 @@ % make it simpler by temporarily defining a function to do this for % us. % \begin{macrocode} -\cs_set:Npn \__cs_tmp:w #1#2#3 +\cs_set:Npn \@@_tmp:w #1#2#3 { \cs_new_protected:cpx { cs_ #1 : #2 } { - \exp_not:N \__cs_generate_from_signature:NNn + \exp_not:N \@@_generate_from_signature:NNn \exp_after:wN \exp_not:N \cs:w cs_ #1 : #3 \cs_end: } } -\cs_new_protected:Npn \__cs_generate_from_signature:NNn #1#2 +\cs_new_protected:Npn \@@_generate_from_signature:NNn #1#2 { - \__cs_split_function:NN #2 \__cs_generate_from_signature:nnNNNn + \@@_split_function:NN #2 \@@_generate_from_signature:nnNNNn #1 #2 } -\cs_new_protected:Npn \__cs_generate_from_signature:nnNNNn #1#2#3#4#5#6 +\cs_new_protected:Npn \@@_generate_from_signature:nnNNNn #1#2#3#4#5#6 { \bool_if:NTF #3 { \str_if_eq_x:nnF { } - { \tl_map_function:nN {#2} \__cs_generate_from_signature:n } + { \tl_map_function:nN {#2} \@@_generate_from_signature:n } { \__msg_kernel_error:nnx { kernel } { non-base-function } { \token_to_str:N #5 } @@ -3071,7 +3182,7 @@ { \token_to_str:N #5 } } } -\cs_new:Npn \__cs_generate_from_signature:n #1 +\cs_new:Npn \@@_generate_from_signature:n #1 { \if:w n #1 \else: \if:w N #1 \else: \if:w T #1 \else: \if:w F #1 \else: #1 \fi: \fi: \fi: \fi: @@ -3079,30 +3190,30 @@ % \end{macrocode} % Then we define the 24 variants beginning with |N|. % \begin{macrocode} -\__cs_tmp:w { set } { Nn } { Npn } -\__cs_tmp:w { set } { Nx } { Npx } -\__cs_tmp:w { set_nopar } { Nn } { Npn } -\__cs_tmp:w { set_nopar } { Nx } { Npx } -\__cs_tmp:w { set_protected } { Nn } { Npn } -\__cs_tmp:w { set_protected } { Nx } { Npx } -\__cs_tmp:w { set_protected_nopar } { Nn } { Npn } -\__cs_tmp:w { set_protected_nopar } { Nx } { Npx } -\__cs_tmp:w { gset } { Nn } { Npn } -\__cs_tmp:w { gset } { Nx } { Npx } -\__cs_tmp:w { gset_nopar } { Nn } { Npn } -\__cs_tmp:w { gset_nopar } { Nx } { Npx } -\__cs_tmp:w { gset_protected } { Nn } { Npn } -\__cs_tmp:w { gset_protected } { Nx } { Npx } -\__cs_tmp:w { gset_protected_nopar } { Nn } { Npn } -\__cs_tmp:w { gset_protected_nopar } { Nx } { Npx } -\__cs_tmp:w { new } { Nn } { Npn } -\__cs_tmp:w { new } { Nx } { Npx } -\__cs_tmp:w { new_nopar } { Nn } { Npn } -\__cs_tmp:w { new_nopar } { Nx } { Npx } -\__cs_tmp:w { new_protected } { Nn } { Npn } -\__cs_tmp:w { new_protected } { Nx } { Npx } -\__cs_tmp:w { new_protected_nopar } { Nn } { Npn } -\__cs_tmp:w { new_protected_nopar } { Nx } { Npx } +\@@_tmp:w { set } { Nn } { Npn } +\@@_tmp:w { set } { Nx } { Npx } +\@@_tmp:w { set_nopar } { Nn } { Npn } +\@@_tmp:w { set_nopar } { Nx } { Npx } +\@@_tmp:w { set_protected } { Nn } { Npn } +\@@_tmp:w { set_protected } { Nx } { Npx } +\@@_tmp:w { set_protected_nopar } { Nn } { Npn } +\@@_tmp:w { set_protected_nopar } { Nx } { Npx } +\@@_tmp:w { gset } { Nn } { Npn } +\@@_tmp:w { gset } { Nx } { Npx } +\@@_tmp:w { gset_nopar } { Nn } { Npn } +\@@_tmp:w { gset_nopar } { Nx } { Npx } +\@@_tmp:w { gset_protected } { Nn } { Npn } +\@@_tmp:w { gset_protected } { Nx } { Npx } +\@@_tmp:w { gset_protected_nopar } { Nn } { Npn } +\@@_tmp:w { gset_protected_nopar } { Nx } { Npx } +\@@_tmp:w { new } { Nn } { Npn } +\@@_tmp:w { new } { Nx } { Npx } +\@@_tmp:w { new_nopar } { Nn } { Npn } +\@@_tmp:w { new_nopar } { Nx } { Npx } +\@@_tmp:w { new_protected } { Nn } { Npn } +\@@_tmp:w { new_protected } { Nx } { Npx } +\@@_tmp:w { new_protected_nopar } { Nn } { Npn } +\@@_tmp:w { new_protected_nopar } { Nx } { Npx } % \end{macrocode} % \end{macro} % @@ -3123,7 +3234,7 @@ % } % The 24 |c| variants simply use \cs{exp_args:Nc}. % \begin{macrocode} -\cs_set:Npn \__cs_tmp:w #1#2 +\cs_set:Npn \@@_tmp:w #1#2 { \cs_new_protected:cpx { cs_ #1 : c #2 } { @@ -3131,30 +3242,30 @@ \exp_after:wN \exp_not:N \cs:w cs_ #1 : N #2 \cs_end: } } -\__cs_tmp:w { set } { n } -\__cs_tmp:w { set } { x } -\__cs_tmp:w { set_nopar } { n } -\__cs_tmp:w { set_nopar } { x } -\__cs_tmp:w { set_protected } { n } -\__cs_tmp:w { set_protected } { x } -\__cs_tmp:w { set_protected_nopar } { n } -\__cs_tmp:w { set_protected_nopar } { x } -\__cs_tmp:w { gset } { n } -\__cs_tmp:w { gset } { x } -\__cs_tmp:w { gset_nopar } { n } -\__cs_tmp:w { gset_nopar } { x } -\__cs_tmp:w { gset_protected } { n } -\__cs_tmp:w { gset_protected } { x } -\__cs_tmp:w { gset_protected_nopar } { n } -\__cs_tmp:w { gset_protected_nopar } { x } -\__cs_tmp:w { new } { n } -\__cs_tmp:w { new } { x } -\__cs_tmp:w { new_nopar } { n } -\__cs_tmp:w { new_nopar } { x } -\__cs_tmp:w { new_protected } { n } -\__cs_tmp:w { new_protected } { x } -\__cs_tmp:w { new_protected_nopar } { n } -\__cs_tmp:w { new_protected_nopar } { x } +\@@_tmp:w { set } { n } +\@@_tmp:w { set } { x } +\@@_tmp:w { set_nopar } { n } +\@@_tmp:w { set_nopar } { x } +\@@_tmp:w { set_protected } { n } +\@@_tmp:w { set_protected } { x } +\@@_tmp:w { set_protected_nopar } { n } +\@@_tmp:w { set_protected_nopar } { x } +\@@_tmp:w { gset } { n } +\@@_tmp:w { gset } { x } +\@@_tmp:w { gset_nopar } { n } +\@@_tmp:w { gset_nopar } { x } +\@@_tmp:w { gset_protected } { n } +\@@_tmp:w { gset_protected } { x } +\@@_tmp:w { gset_protected_nopar } { n } +\@@_tmp:w { gset_protected_nopar } { x } +\@@_tmp:w { new } { n } +\@@_tmp:w { new } { x } +\@@_tmp:w { new_nopar } { n } +\@@_tmp:w { new_nopar } { x } +\@@_tmp:w { new_protected } { n } +\@@_tmp:w { new_protected } { x } +\@@_tmp:w { new_protected_nopar } { n } +\@@_tmp:w { new_protected_nopar } { x } % \end{macrocode} % \end{macro} % @@ -3186,8 +3297,12 @@ % % \subsection{Diagnostic functions} % -% \begin{macro}[int]{\__kernel_register_show:N, \__kernel_register_show:c} -% \begin{macro}[aux]{\__kernel_register_show_aux:n} +% \begin{macrocode} +%<@@=kernel> +% \end{macrocode} +% +% \begin{macro}[int]{\@@_register_show:N, \@@_register_show:c} +% \begin{macro}[aux]{\@@_register_show_aux:n} % Simply using the \tn{showthe} primitive does not allow for % line-wrapping, so instead use \cs{__msg_show_variable:NNNnn} (defined % in \pkg{l3msg}). This checks that the variable exists (using @@ -3197,26 +3312,26 @@ % \tn{currentgrouptype}) altered by the line-wrapping code would show % wrong values. % \begin{macrocode} -\cs_new_protected:Npn \__kernel_register_show:N #1 - { \exp_args:No \__kernel_register_show_aux:nN { \tex_the:D #1 } #1 } -\cs_new_protected:Npn \__kernel_register_show_aux:nN #1#2 +\cs_new_protected:Npn \@@_register_show:N #1 + { \exp_args:No \@@_register_show_aux:nN { \tex_the:D #1 } #1 } +\cs_new_protected:Npn \@@_register_show_aux:nN #1#2 { \__msg_show_variable:NNNnn #2 \cs_if_exist:NTF ? { } { > ~ \token_to_str:N #2 = #1 } } -\cs_new_protected:Npn \__kernel_register_show:c - { \exp_args:Nc \__kernel_register_show:N } +\cs_new_protected:Npn \@@_register_show:c + { \exp_args:Nc \@@_register_show:N } % \end{macrocode} % \end{macro} % \end{macro} % -% \begin{macro}[int]{\__kernel_register_log:N, \__kernel_register_log:c} -% Redirect the output of \cs{__kernel_register_show:N} to the log. +% \begin{macro}[int]{\@@_register_log:N, \@@_register_log:c} +% Redirect the output of \cs{@@_register_show:N} to the log. % \begin{macrocode} -\cs_new_protected:Npn \__kernel_register_log:N - { \__msg_log_next: \__kernel_register_show:N } -\cs_new_protected:Npn \__kernel_register_log:c - { \exp_args:Nc \__kernel_register_log:N } +\cs_new_protected:Npn \@@_register_log:N + { \__msg_log_next: \@@_register_show:N } +\cs_new_protected:Npn \@@_register_log:c + { \exp_args:Nc \@@_register_log:N } % \end{macrocode} % \end{macro} % @@ -3269,38 +3384,42 @@ % % \subsection{Breaking out of mapping functions} % -% \begin{macro}[EXP]{\__prg_break_point:Nn, \__prg_map_break:Nn} +% \begin{macrocode} +%<@@=prg> +% \end{macrocode} +% +% \begin{macro}[EXP]{\@@_break_point:Nn, \@@_map_break:Nn} % In inline mappings, the nesting level must be reset % at the end of the mapping, even when the user decides % to break out. This is done by putting the code that -% must be performed as an argument of \cs{__prg_break_point:Nn}. +% must be performed as an argument of \cs{@@_break_point:Nn}. % The breaking functions are then defined to jump to -% that point and perform the argument of \cs{__prg_break_point:Nn}, +% that point and perform the argument of \cs{@@_break_point:Nn}, % before the user's code (if any). There is a check that we close the % correct loop, otherwise we continue breaking. % \begin{macrocode} -\cs_new_eq:NN \__prg_break_point:Nn \use_ii:nn -\cs_new:Npn \__prg_map_break:Nn #1#2#3 \__prg_break_point:Nn #4#5 +\cs_new_eq:NN \@@_break_point:Nn \use_ii:nn +\cs_new:Npn \@@_map_break:Nn #1#2#3 \@@_break_point:Nn #4#5 { #5 \if_meaning:w #1 #4 \exp_after:wN \use_iii:nnn \fi: - \__prg_map_break:Nn #1 {#2} + \@@_map_break:Nn #1 {#2} } % \end{macrocode} % \end{macro} % -% \begin{macro}{\__prg_break_point:} -% \begin{macro}{\__prg_break:, \__prg_break:n} -% Very simple analogues of \cs{__prg_break_point:Nn} and -% \cs{__prg_map_break:Nn}, for use in fast short-term recursions which +% \begin{macro}{\@@_break_point:} +% \begin{macro}{\@@_break:, \@@_break:n} +% Very simple analogues of \cs{@@_break_point:Nn} and +% \cs{@@_map_break:Nn}, for use in fast short-term recursions which % are not mappings, do not need to support nesting, and in which % nothing has to be done at the end of the loop. % \begin{macrocode} -\cs_new_eq:NN \__prg_break_point: \prg_do_nothing: -\cs_new:Npn \__prg_break: #1 \__prg_break_point: { } -\cs_new:Npn \__prg_break:n #1#2 \__prg_break_point: {#1} +\cs_new_eq:NN \@@_break_point: \prg_do_nothing: +\cs_new:Npn \@@_break: #1 \@@_break_point: { } +\cs_new:Npn \@@_break:n #1#2 \@@_break_point: {#1} % \end{macrocode} % \end{macro} % \end{macro} |