summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3basics.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3basics.dtx449
1 files changed, 299 insertions, 150 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
index 078db9864a7..120abdb963c 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
@@ -7,7 +7,7 @@
% license or (at your option) any later version. The latest version
% of this license is in the file
%
-% http://www.latex-project.org/lppl.txt
+% https://www.latex-project.org/lppl.txt
%
% This file is part of the "l3kernel bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
@@ -21,7 +21,7 @@
% for those people who are interested.
%
%<*driver>
-\documentclass[full]{l3doc}
+\documentclass[full,kernel]{l3doc}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
@@ -41,7 +41,7 @@
% }^^A
% }
%
-% \date{Released 2017/11/14}
+% \date{Released 2017/12/05}
%
% \maketitle
%
@@ -1259,6 +1259,33 @@
% \cs{cs_if_exist_p:N}, and if not raises a kernel-level error.
% \end{function}
%
+% \begin{function}{\__debug_chk_var_scope:NN}
+% \begin{syntax}
+% \cs{__debug_chk_var_scope:NN} \meta{scope} \meta{var}
+% \end{syntax}
+% Checks the \meta{var} has the correct \meta{scope}, and if not
+% raises a kernel-level error. This function is only created if
+% debugging is enabled. The \meta{scope} is a single letter |l|, |g|,
+% |c| denoting local variables, global variables, or constants. More
+% precisely, if the variable name starts with a letter and an
+% underscore (normal \pkg{expl3} convention) the function checks that
+% this single letter matches the \meta{scope}. Otherwise the function
+% cannot know the scope \meta{var} the first time: instead, it defines
+% |\__debug_chk_/|\meta{var name} to store that information for the
+% next call. Thus, if a given \meta{var} is subject to assignments of
+% different scopes a kernel error will result.
+% \end{function}
+%
+% \begin{function}{\__debug_chk_var_local:N, \__debug_chk_var_global:N}
+% \begin{syntax}
+% \cs{__debug_chk_var_local:N} \meta{var}
+% \cs{__debug_chk_var_global:N} \meta{var}
+% \end{syntax}
+% Applies \cs{__debug_chk_var_exist:N} \meta{var}, then
+% \cs{__debug_chk_var_scope:NN} \meta{scope} \meta{var}, where
+% \meta{scope} is |l| or~|g|.
+% \end{function}
+%
% \begin{function}{\__debug_log:x}
% \begin{syntax}
% \cs{__debug_log:x} \Arg{message text}
@@ -1269,15 +1296,6 @@
% This function is only created if debugging is enabled.
% \end{function}
%
-% \begin{function}{\__debug_suspend_log:, \__debug_resume_log:}
-% \begin{syntax}
-% \cs{__debug_suspend_log:} \ldots{} \cs{__debug_log:x} \ldots{} \cs{__debug_resume_log:}
-% \end{syntax}
-% Any \cs{__debug_log:x} command between \cs{__debug_suspend_log:} and
-% \cs{__debug_resume_log:} is suppressed. These two commands can be
-% nested. These functions are only created if debugging is enabled.
-% \end{function}
-%
% \begin{function}{\__debug_patch:nnNNpn}
% \begin{syntax}
% \cs{__debug_patch:nnNNpn} \Arg{before} \Arg{after}
@@ -1331,6 +1349,25 @@
% counterpart.
% \end{function}
%
+% \begin{function}
+% {\__debug_patch_args:nnnNNpn, \__debug_patch_conditional_args:nnnNNpnn}
+% \begin{syntax}
+% \cs{__debug_patch_args:nnnNNpn} \Arg{before} \Arg{after} \Arg{arguments}
+% \meta{definition} \meta{function} \meta{parameters} \Arg{code}
+% \end{syntax}
+% A combination of \cs{__debug_patch:nnNNpn} and
+% \cs{__debug_patch_args:nNNpn}.
+% \end{function}
+%
+% \begin{function}{\__kernel_check_defined:NT}
+% \begin{syntax}
+% \cs{__kernel_check_defined:NT} \meta{variable} \Arg{true code}
+% \end{syntax}
+% If \meta{variable} is not defined (according to
+% \cs{cs_if_exist:NTF}), this triggers an error, otherwise the
+% \meta{true code} is run.
+% \end{function}
+%
% \begin{function}{\__kernel_register_show:N, \__kernel_register_show:c}
% \begin{syntax}
% \cs{__kernel_register_show:N} \meta{register}
@@ -1744,7 +1781,7 @@
%<@@=debug>
% \end{macrocode}
%
-% \begin{macro}[int]{\@@:TF}
+% \begin{macro}{\@@: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
@@ -1798,15 +1835,59 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux]
+% \begin{macro}{\debug_suspend:, \debug_resume:}
+% \begin{macro}{\@@_suspended:T}
+% \begin{macro}{\l_@@_suspended_tl}
+% Suspend and resume locally all debug-related errors and logging
+% except deprecation errors. The \cs{debug_suspend:} and \cs{debug_resume:}
+% pairs can be nested. We keep track of nesting in a token list
+% containing a number of periods. At first begin with the
+% \enquote{non-suspended} version of \cs{@@_suspended:T}.
+% \begin{macrocode}
+\@@:TF
+ {
+ \cs_set_nopar:Npn \l_@@_suspended_tl { }
+ \cs_set_protected:Npn \debug_suspend:
+ {
+ \tl_put_right:Nn \l_@@_suspended_tl { . }
+ \cs_set_eq:NN \@@_suspended:T \use:n
+ }
+ \cs_set_protected:Npn \debug_resume:
+ {
+ \tl_set:Nx \l_@@_suspended_tl
+ { \tl_tail:N \l_@@_suspended_tl }
+ \tl_if_empty:NT \l_@@_suspended_tl
+ {
+ \cs_set_eq:NN \@@_suspended:T \use_none:n
+ }
+ }
+ \cs_set:Npn \@@_suspended:T #1 { }
+ }
+ {
+ \cs_set_protected:Npn \debug_suspend: { }
+ \cs_set_protected:Npn \debug_resume: { }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}
% {\@@_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{macro}{\@@_chk_var_exist:N}
+% \begin{macro}{\@@_chk_cs_exist:N, \@@_chk_cs_exist:c}
+% \begin{macro}{\@@_chk_var_local:N, \@@_chk_var_global:N}
+% \begin{macro}{\@@_chk_var_scope:NN}
+% When debugging is enabled these two functions set up functions that
+% test their argument (when \texttt{check-declarations} is active)
+% \begin{itemize}
+% \item \cs{@@_chk_var_exist:N} and \cs{@@_chk_cs_exist:N}, two
+% functions that test that their argument is defined;
+% \item \cs{@@_chk_var_scope:NN} that checks that its argument |#2|
+% has scope |#1|.
+% \item \cs{@@_chk_var_local:N} and \cs{@@_chk_var_global:N} that
+% perform both checks.
+% \end{itemize}
% \begin{macrocode}
\@@:TF
{
@@ -1814,6 +1895,7 @@
{
\cs_set_protected:Npn \@@_chk_var_exist:N ##1
{
+ \@@_suspended:T \use_none:nnn
\cs_if_exist:NF ##1
{
\__msg_kernel_error:nnx { kernel } { non-declared-variable }
@@ -1822,17 +1904,38 @@
}
\cs_set_protected:Npn \@@_chk_cs_exist:N ##1
{
+ \@@_suspended:T \use_none:nnn
\cs_if_exist:NF ##1
{
\__msg_kernel_error:nnx { kernel } { command-not-defined }
{ \token_to_str:N ##1 }
}
}
+ \cs_set_protected:Npn \@@_chk_var_scope:NN
+ {
+ \@@_suspended:T \use_none:nnn
+ \@@_chk_var_scope_aux:NN
+ }
+ \cs_set_protected:Npn \@@_chk_var_local:N ##1
+ {
+ \@@_suspended:T \use_none:nnnnn
+ \@@_chk_var_exist:N ##1
+ \@@_chk_var_scope_aux:NN l ##1
+ }
+ \cs_set_protected:Npn \@@_chk_var_global:N ##1
+ {
+ \@@_suspended:T \use_none:nnnnn
+ \@@_chk_var_exist:N ##1
+ \@@_chk_var_scope_aux:NN g ##1
+ }
}
\exp_args:Nc \cs_set_protected:Npn { @@_check-declarations_off: }
{
\cs_set_protected:Npn \@@_chk_var_exist:N ##1 { }
\cs_set_protected:Npn \@@_chk_cs_exist:N ##1 { }
+ \cs_set_protected:Npn \@@_chk_var_local:N ##1 { }
+ \cs_set_protected:Npn \@@_chk_var_global:N ##1 { }
+ \cs_set_protected:Npn \@@_chk_var_scope:NN ##1##2 { }
}
\cs_set_protected:Npn \@@_chk_cs_exist:c
{ \exp_args:Nc \@@_chk_cs_exist:N }
@@ -1847,11 +1950,64 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
-% \begin{macro}[aux]
+% \begin{macro}{\@@_chk_var_scope_aux:NN}
+% \begin{macro}{\@@_chk_var_scope_aux:Nn}
+% \begin{macro}{\@@_chk_var_scope_aux:NNn}
+% First check whether the name of the variable |#2| starts with
+% \meta{letter}|_|. If it does then pass that letter, the
+% \meta{scope}, and the variable name to
+% \cs{@@_chk_var_scope_aux:NNn}. That function compares the two
+% letters and triggers an error if they differ (the \cs{scan_stop:}
+% case is not reachable here). If the second character was not |_|
+% then pass the same data to the same auxiliary, except for its first
+% argument which is now a control sequence. That control sequence is
+% actually a token list (but to avoid triggering the checking code we
+% manipulate it using \cs{cs_set_nopar:Npn}) containing a single
+% letter \meta{scope} according to what the first assignment to the
+% given variable was.
+% \begin{macrocode}
+\@@:TF
+ {
+ \cs_set_protected:Npn \@@_chk_var_scope_aux:NN #1#2
+ { \exp_args:NNf \@@_chk_var_scope_aux:Nn #1 { \cs_to_str:N #2 } }
+ \cs_set_protected:Npn \@@_chk_var_scope_aux:Nn #1#2
+ {
+ \if:w _ \use_i:nn \use_i_delimit_by_q_stop:nw #2 ? ? \q_stop
+ \exp_after:wN \@@_chk_var_scope_aux:NNn
+ \use_i_delimit_by_q_stop:nw #2 ? \q_stop
+ #1 {#2}
+ \else:
+ \exp_args:Nc \@@_chk_var_scope_aux:NNn
+ { @@_chk_/ #2 }
+ #1 {#2}
+ \fi:
+ }
+ \cs_set_protected:Npn \@@_chk_var_scope_aux:NNn #1#2#3
+ {
+ \if:w #1 #2
+ \else:
+ \if:w #1 \scan_stop:
+ \cs_gset_nopar:Npn #1 {#2}
+ \else:
+ \__msg_kernel_error:nnxxx { kernel } { local-global }
+ {#1} {#2} { \iow_char:N \\ #3 }
+ \fi:
+ \fi:
+ }
+ }
+ { }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}
% {\@@_check-expressions_on:, \@@_check-expressions_off:}
-% \begin{macro}[int]{\@@_chk_expr:nNnN}
-% \begin{macro}[aux]{\@@_chk_expr_aux:nNnN}
+% \begin{macro}{\@@_chk_expr:nNnN}
+% \begin{macro}{\@@_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
@@ -1877,6 +2033,7 @@
{
\cs_set:Npn \@@_chk_expr:nNnN ##1##2
{
+ \@@_suspended:T { ##1 \use_none:nnnnnnn }
\exp_after:wN \@@_chk_expr_aux:nNnN
\exp_after:wN { \tex_the:D ##2 ##1 \tex_relax:D }
##2
@@ -1906,48 +2063,25 @@
% \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{@@_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{@@_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{@@_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{macro}{\@@_log-functions_on:, \@@_log-functions_off:}
+% \begin{macro}{\@@_log:x}
+% These two functions (corresponding to the \pkg{expl3} option
+% \texttt{log-functions}) 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).
+% 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}
\@@:TF
{
\exp_args:Nc \cs_set_protected:Npn { @@_log-functions_on: }
{
- \cs_set_protected:Npn \@@_log:x { \iow_log:x }
- \cs_set_protected:Npn \@@_suspend_log:
- {
- \cs_set_protected:Npx \@@_resume_log:
- {
- \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 \@@_log:x { \use_none:n }
- }
- \cs_set_protected:Npn \@@_resume_log: { }
+ \cs_set_protected:Npn \@@_log:x
+ { \@@_suspended:T \use_none:nn \iow_log:x }
}
\exp_args:Nc \cs_set_protected:Npn { @@_log-functions_off: }
- {
- \cs_set_protected:Npn \@@_log:x { \use_none:n }
- \cs_set_protected:Npn \@@_suspend_log: { }
- \cs_set_protected:Npn \@@_resume_log: { }
- }
+ { \cs_set_protected:Npn \@@_log:x { \use_none:n } }
\tex_ifodd:D \l@expl@log@functions@bool
\use:c { @@_log-functions_on: }
\else:
@@ -1963,7 +2097,7 @@
% \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
+% two token lists, mostly filled up by calls to
% \cs{@@_deprecation:nnNNpn} in each module.
% \begin{macrocode}
\@@:TF
@@ -1980,8 +2114,8 @@
% \end{variable}
% \end{macro}
%
-% \begin{macro}[int]{\@@_deprecation:nnNNpn}
-% \begin{macro}[aux]{\@@_deprecation_aux:nnNnn}
+% \begin{macro}{\@@_deprecation:nnNNpn}
+% \begin{macro}{\@@_deprecation_aux:nnNnn}
% Grab a definition (at present, must be \cs{cs_new_protected:Npn}).
% Add to \cs{g_@@_deprecation_on_tl} some code that makes the
% defined macro |#3| outer (and defines it as an error). Add to
@@ -2034,10 +2168,10 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[int]
+% \begin{macro}
% {\@@_patch:nnNNpn, \@@_patch_conditional:nNNpnn}
-% \begin{macro}[aux]
-% {\@@_patch_aux:nnNNnn, \@@_patch_aux:nNNnnn}
+% \begin{macro}
+% {\@@_patch_aux:nnnn, \@@_patch_auxii:nnnn}
% 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
@@ -2048,13 +2182,13 @@
\@@:TF
{
\cs_set_protected:Npn \@@_patch:nnNNpn #1#2#3#4#5#
- { \@@_patch_aux:nnNNnn {#1} {#2} #3 #4 {#5} }
+ { \@@_patch_aux:nnnn {#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 \@@_patch_aux:nNNnnn #1#2#3#4#5#6
- { #2 #3 #4 {#5} { #1 #6 } }
+ { \@@_patch_auxii:nnnn {#1} { #2 #3 #4 } }
+ \cs_set_protected:Npn \@@_patch_aux:nnnn #1#2#3#4
+ { #3 { #1 #4 #2 } }
+ \cs_set_protected:Npn \@@_patch_auxii:nnnn #1#2#3#4
+ { #2 {#3} { #1 #4 } }
}
{
\cs_set_protected:Npn \@@_patch:nnNNpn #1#2 { }
@@ -2064,48 +2198,57 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[int]
+% \begin{macro}
% {\@@_patch_args:nNNpn, \@@_patch_conditional_args:nNNpnn}
-% \begin{macro}[aux]
+% \begin{macro}
+% {\@@_patch_args:nnnNNpn, \@@_patch_conditional_args:nnnNNpnn}
+% \begin{macro}
% {
% \@@_tmp:w,
-% \@@_patch_args_aux:nNNnn,
-% \@@_patch_args_aux:nNNnnn
+% \@@_patch_args_aux:nnnNNnn,
+% \@@_patch_args_aux:nnnNNnnn,
+% \@@_patch_args_aux:nnnn
% }
% 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
% \meta{code}. Then perform the definition as if that new \meta{code}
-% 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.
+% was directly typed in the file.
% \begin{macrocode}
+\cs_set_protected:Npn \@@_patch_args:nNNpn
+ { \@@_patch_args:nnnNNpn { } { } }
+\cs_set_protected:Npn \@@_patch_conditional_args:nNNpnn
+ { \@@_patch_conditional_args:nnnNNpnn { } { } }
\@@:TF
{
- \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_protected:Npn \@@_patch_args:nnnNNpn #1#2#3#4#5#6#
+ { \@@_patch_args_aux:nnnNNnn {#1} {#2} {#3} #4 #5 {#6} }
+ \cs_set_protected:Npn \@@_patch_conditional_args:nnnNNpnn #1#2#3#4#5#6#
+ { \@@_patch_args_aux:nnnNNnnn {#1} {#2} {#3} #4 #5 {#6} }
+ \cs_set_protected:Npn \@@_patch_args_aux:nnnNNnn #1#2#3#4#5#6#7
{
- \cs_set:Npn \@@_tmp:w #4 {#5}
- \exp_after:wN \@@_patch_aux:nnNNnn \exp_after:wN
- { \@@_tmp:w #1 } { } #2 #3 {#4} { }
+ \cs_set:Npn \@@_tmp:w #6 {#7}
+ \exp_after:wN \@@_patch_args_aux:nnnn \exp_after:wN
+ { \@@_tmp:w #3 } { #4 #5 #6 } {#1} {#2}
}
- \cs_set_protected:Npn \@@_patch_args_aux:nNNnnn #1#2#3#4#5#6
+ \cs_set_protected:Npn \@@_patch_args_aux:nnnNNnnn #1#2#3#4#5#6#7#8
{
- \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:Npn \@@_tmp:w #6 {#8}
+ \exp_after:wN \@@_patch_args_aux:nnnn \exp_after:wN
+ { \@@_tmp:w #3 } { #4 #5 #6 {#7} } {#1} {#2}
}
+ \cs_set_protected:Npn \@@_patch_args_aux:nnnn #1#2#3#4
+ { #2 { #3 #1 #4 } }
}
{
- \cs_set_protected:Npn \@@_patch_args:nNNpn #1 { }
- \cs_set_protected:Npn \@@_patch_conditional_args:nNNpnn #1 { }
+ \cs_set_protected:Npn \@@_patch_args:nnnNNpn #1#2#3 { }
+ \cs_set_protected:Npn \@@_patch_conditional_args:nnnNNpnn #1#2#3 { }
}
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Conditional processing and definitions}
%
@@ -2161,7 +2304,7 @@
% \prg_set_protected_conditional:Npnn ,
% \prg_new_protected_conditional:Npnn ,
% }
-% \begin{macro}[aux]{\@@_generate_conditional_parm:nnNpnn}
+% \begin{macro}{\@@_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
@@ -2196,7 +2339,7 @@
% \prg_set_protected_conditional:Nnn ,
% \prg_new_protected_conditional:Nnn ,
% }
-% \begin{macro}[aux]
+% \begin{macro}
% {
% \@@_generate_conditional_count:nnNnn ,
% \@@_generate_conditional_count:nnNnnnn
@@ -2243,7 +2386,7 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[aux]
+% \begin{macro}
% {
% \@@_generate_conditional:nnNnnnnn,
% \@@_generate_conditional:nnnnnnw
@@ -2303,7 +2446,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux]
+% \begin{macro}
% {
% \@@_generate_p_form:wnnnnnn,
% \@@_generate_TF_form:wnnnnnn,
@@ -2359,7 +2502,7 @@
% \end{macro}
%
% \begin{macro}{\prg_set_eq_conditional:NNn, \prg_new_eq_conditional:NNn}
-% \begin{macro}[aux]{\@@_set_eq_conditional:NNNn}
+% \begin{macro}{\@@_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}
@@ -2387,12 +2530,12 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[aux]
+% \begin{macro}
% {
% \@@_set_eq_conditional:nnNnnNNw ,
% \@@_set_eq_conditional_loop:nnnnNw
% }
-% \begin{macro}[aux, EXP]
+% \begin{macro}[EXP]
% {
% \@@_set_eq_conditional_p_form:nnn ,
% \@@_set_eq_conditional_TF_form:nnn ,
@@ -2485,7 +2628,7 @@
% \end{macrocode}
%
% \begin{macro}[EXP]{\cs_to_str:N}
-% \begin{macro}[aux, EXP]{\@@_to_str:N, \@@_to_str:w}
+% \begin{macro}[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:
@@ -2549,8 +2692,8 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP, int]{\@@_split_function:NN}
-% \begin{macro}[aux, EXP]
+% \begin{macro}[EXP]{\@@_split_function:NN}
+% \begin{macro}[EXP]
% {\@@_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
@@ -2597,7 +2740,7 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP, int]
+% \begin{macro}[EXP]
% {\@@_get_function_name:N, \@@_get_function_signature:N}
% Simple wrappers.
% \begin{macrocode}
@@ -2736,7 +2879,7 @@
% us to generate error messages. The next few definitions here are
% only temporary, they will be redefined later on.
%
-% \begin{macro}[int]
+% \begin{macro}
% {\__msg_kernel_error:nnxx, \__msg_kernel_error:nnx, \__msg_kernel_error:nn}
% If an internal error occurs before \LaTeX3 has loaded \pkg{l3msg} then
% the code should issue a usable if terse error message and halt. This
@@ -2784,7 +2927,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[int]{\__chk_if_free_cs:N, \__chk_if_free_cs:c}
+% \begin{macro}{\__chk_if_free_cs:N, \__chk_if_free_cs:c}
% This command is called by \cs{cs_new_nopar:Npn} and \cs{cs_new_eq:NN}
% \emph{etc.}\
% to make sure that the argument sequence is not already in use. If
@@ -2821,7 +2964,7 @@
% \cs_new_protected_nopar:Npn , \cs_new_protected_nopar:Npx ,
% \cs_new_protected:Npn , \cs_new_protected:Npx
% }
-% \begin{macro}[int]{\@@_tmp:w}
+% \begin{macro}{\@@_tmp:w}
% Function which check that the control sequence is free before
% defining it.
% \begin{macrocode}
@@ -2996,8 +3139,8 @@
%<@@=cs>
% \end{macrocode}
%
-% \begin{macro}[int]{\@@_parm_from_arg_count:nnF}
-% \begin{macro}[aux]{\@@_parm_from_arg_count_test:nnF}
+% \begin{macro}{\@@_parm_from_arg_count:nnF}
+% \begin{macro}{\@@_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,
@@ -3015,7 +3158,7 @@
\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:
+ \if_case:w \__int_eval:n {#2}
{ }
\or: { ##1 }
\or: { ##1##2 }
@@ -3050,8 +3193,8 @@
%<@@=cs>
% \end{macrocode}
%
-% \begin{macro}[EXP, int]{\@@_count_signature:N, \@@_count_signature:c}
-% \begin{macro}[aux, EXP]{\@@_count_signature:nnN}
+% \begin{macro}[EXP]{\@@_count_signature:N, \@@_count_signature:c}
+% \begin{macro}[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
@@ -3301,75 +3444,81 @@
%<@@=kernel>
% \end{macrocode}
%
-% \begin{macro}[int]{\@@_register_show:N, \@@_register_show:c}
-% \begin{macro}[aux]{\@@_register_show_aux:n}
+% \begin{macro}{\@@_check_defined:NT}
+% Error if the variable |#1| is not defined.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_check_defined:NT #1#2
+ {
+ \cs_if_exist:NTF #1
+ {#2}
+ {
+ \__msg_kernel_error:nnx { kernel } { variable-not-defined }
+ { \token_to_str:N #1 }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}
+% {\@@_register_show:N, \@@_register_show:c, \@@_register_log:N, \@@_register_log:c}
+% \begin{macro}{\@@_register_show_aux:NN, \@@_register_show_aux:nNN}
% 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
-% \cs{cs_if_exist:NTF}), then displays the third argument, namely
+% line-wrapping, so instead use \cs{tl_show:n} and \cs{tl_log:n} (defined
+% in \pkg{l3tl} and that performs line-wrapping). This displays
% |>~|\meta{variable}|=|\meta{value}. We expand the value before-hand
% as otherwise some integers (such as \tn{currentgrouplevel} or
% \tn{currentgrouptype}) altered by the line-wrapping code would show
% wrong values.
% \begin{macrocode}
-\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 \@@_register_show:N
+ { \@@_register_show_aux:NN \tl_show:n }
\cs_new_protected:Npn \@@_register_show:c
{ \exp_args:Nc \@@_register_show:N }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \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 \@@_register_log:N
- { \__msg_log_next: \@@_register_show:N }
+ { \@@_register_show_aux:NN \tl_log:n }
\cs_new_protected:Npn \@@_register_log:c
{ \exp_args:Nc \@@_register_log:N }
+\cs_new_protected:Npn \@@_register_show_aux:NN #1#2
+ {
+ \@@_check_defined:NT #2
+ {
+ \exp_args:No \@@_register_show_aux:nNN
+ { \tex_the:D #2 } #2 #1
+ }
+ }
+\cs_new_protected:Npn \@@_register_show_aux:nNN #1#2#3
+ { \exp_args:No #3 { \token_to_str:N #2 = #1 } }
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\cs_show:N, \cs_show:c}
+% \begin{macro}{\cs_show:N, \cs_show:c, \cs_log:N, \cs_log:c, \@@_show:NN}
% Some control sequences have a very long name or meaning. Thus,
% simply using \TeX{}'s primitive \tn{show} could lead to overlong
% lines. The output of this primitive is mimicked to some extent,
-% then the re-built string is given to \cs{iow_wrap:nnnN} for
+% then the re-built string is given to \cs{tl_show:n} or \cs{tl_log:n} for
% line-wrapping. We must expand the meaning before passing it to the
% wrapping code as otherwise we would wrongly see the definitions that
% are in place there. To get correct escape characters, set the
% \tn{escapechar} in a group; this also localizes the assignment
-% performed by \texttt{x}-expansion. The \cs{cs_show:c} command also
-% converts its argument to a control sequence within a group to avoid
+% performed by \texttt{x}-expansion. The \cs{cs_show:c} and \cs{cs_log:c} commands
+% convert their argument to a control sequence within a group to avoid
% showing \tn{relax} for undefined control sequences.
% \begin{macrocode}
-\cs_new_protected:Npn \cs_show:N #1
+\cs_new_protected:Npn \cs_show:N { \@@_show:NN \tl_show:n }
+\cs_new_protected:Npn \cs_show:c
+ { \group_begin: \exp_args:NNc \group_end: \cs_show:N }
+\cs_new_protected:Npn \cs_log:N { \@@_show:NN \tl_log:n }
+\cs_new_protected:Npn \cs_log:c
+ { \group_begin: \exp_args:NNc \group_end: \cs_log:N }
+\cs_new_protected:Npn \@@_show:NN #1#2
{
\group_begin:
\int_set:Nn \tex_escapechar:D { `\\ }
\exp_args:NNx
\group_end:
- \__msg_show_wrap:n { > ~ \token_to_str:N #1 = \cs_meaning:N #1 }
+ #1 { \token_to_str:N #2 = \cs_meaning:N #2 }
}
-\cs_new_protected:Npn \cs_show:c
- { \group_begin: \exp_args:NNc \group_end: \cs_show:N }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\cs_log:N, \cs_log:c}
-% Use \cs{cs_show:N} or \cs{cs_show:c} after calling
-% \cs{__msg_log_next:} to redirect their output to the log file only.
-% Note that \cs{cs_log:c} is not just a variant of \cs{cs_log:N} as
-% the csname should be turned to a control sequence within a group
-% (see \cs{cs_show:c}).
-% \begin{macrocode}
-\cs_new_protected:Npn \cs_log:N { \__msg_log_next: \cs_show:N }
-\cs_new_protected:Npn \cs_log:c { \__msg_log_next: \cs_show:c }
% \end{macrocode}
% \end{macro}
%