summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3tl.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3tl.dtx60
1 files changed, 51 insertions, 9 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
index c7038b08d12..30a9612af15 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2021-02-18}
+% \date{Released 2021-05-07}
%
% \maketitle
%
@@ -521,7 +521,7 @@
% available.
% \end{function}
%
-% \section{Mapping to token lists}
+% \section{Mapping over token lists}
%
% All mappings are done at the current group level, \emph{i.e.}~any
% local assignments made by the \meta{function} or \meta{code} discussed
@@ -583,7 +583,7 @@
% \tl_map_tokens:Nn \l_my_tl { \prg_replicate:nn { 2 } }
% \end{verbatim}
% expands to twice each item in the \meta{tl~var}: for each item in
-% |\l_my_tl| the function \cs{prg_replicate:nn} receives |2| and
+% \cs[no-index]{l_my_tl} the function \cs{prg_replicate:nn} receives |2| and
% \meta{item} as its two arguments. The function
% \cs{tl_map_inline:Nn} is typically faster but is not expandable.
% \end{function}
@@ -1169,7 +1169,7 @@
%
% \section{Viewing token lists}
%
-% \begin{function}[updated = 2015-08-01]{\tl_show:N, \tl_show:c}
+% \begin{function}[updated = 2021-04-29]{\tl_show:N, \tl_show:c}
% \begin{syntax}
% \cs{tl_show:N} \meta{tl~var}
% \end{syntax}
@@ -1191,7 +1191,7 @@
% \end{texnote}
% \end{function}
%
-% \begin{function}[added = 2014-08-22, updated = 2015-08-01]{\tl_log:N, \tl_log:c}
+% \begin{function}[added = 2014-08-22, updated = 2021-04-29]{\tl_log:N, \tl_log:c}
% \begin{syntax}
% \cs{tl_log:N} \meta{tl~var}
% \end{syntax}
@@ -2458,7 +2458,7 @@
% \end{macro}
% \end{macro}
%
-% \subsection{Mapping to token lists}
+% \subsection{Mapping over token lists}
%
% \begin{macro}{\tl_map_function:nN}
% \begin{macro}{\tl_map_function:NN, \tl_map_function:cN}
@@ -2814,7 +2814,7 @@
% \begin{macro}{\tl_head:w,\@@_tl_head:w}
% \begin{macro}{\tl_tail:N, \tl_tail:n, \tl_tail:V, \tl_tail:v, \tl_tail:f}
% Finding the head of a token list expandably always strips braces, which
-% is fine as this is consistent with for example mapping to a list. The
+% is fine as this is consistent with for example mapping over a list. The
% empty brace groups in \cs{tl_head:n} ensure that a blank argument gives an
% empty result. The result is returned within the \tn{unexpanded} primitive.
% The approach here is to use \cs{if_false:} to allow us to use |}| as
@@ -3531,8 +3531,16 @@
{
\__kernel_chk_defined:NT #2
{
- \exp_args:Ne #1
- { \token_to_str:N #2 = \__kernel_exp_not:w \exp_after:wN {#2} }
+ \exp_args:Nf \tl_if_empty:nTF
+ { \cs_prefix_spec:N #2 \cs_argument_spec:N #2 }
+ {
+ \exp_args:Ne #1
+ { \token_to_str:N #2 = \__kernel_exp_not:w \exp_after:wN {#2} }
+ }
+ {
+ \__kernel_msg_error:nnxxx { kernel } { bad-type }
+ { \token_to_str:N #2 } { \token_to_meaning:N #2 } { tl }
+ }
}
}
% \end{macrocode}
@@ -3584,6 +3592,40 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\__kernel_chk_tl_type:NnnT}
+% Helper for checking that |#1| has the correct internal structure to
+% be of a certain type. Make sure that it is defined and that it is a
+% token list, namely a macro with no \tn{long} nor \tn{protected}
+% prefix. Then compare |#1| to an attempt at reconstructing a valid
+% structure of the given type using |#2| (see implementation of
+% \cs{seq_show:N} for instance). If that is successful run the
+% requested code~|#4|.
+% \begin{macrocode}
+\cs_new_protected:Npn \__kernel_chk_tl_type:NnnT #1#2#3#4
+ {
+ \__kernel_chk_defined:NT #1
+ {
+ \exp_args:Nf \tl_if_empty:nTF
+ { \cs_prefix_spec:N #1 \cs_argument_spec:N #1 }
+ {
+ \tl_set:Nx \l_@@_internal_a_tl {#3}
+ \tl_if_eq:NNTF #1 \l_@@_internal_a_tl
+ {#4}
+ {
+ \__kernel_msg_error:nnxxxx { kernel } { bad-type }
+ { \token_to_str:N #1 } { \tl_to_str:N #1 }
+ {#2} { \tl_to_str:N \l_@@_internal_a_tl }
+ }
+ }
+ {
+ \__kernel_msg_error:nnxxx { kernel } { bad-type }
+ { \token_to_str:N #1 } { \token_to_meaning:N #1 } {#2}
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Internal scan marks}
%
% \begin{variable}{\s_@@_nil,\s_@@_mark,\s_@@_stop}