diff options
author | Karl Berry <karl@freefriends.org> | 2017-07-15 21:27:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-07-15 21:27:01 +0000 |
commit | b1ce47fe4d0e1f06d1b019c3c6eb5f1b0ecd5e14 (patch) | |
tree | 58362abe4b603bb5f6db898b9b835bc8af730b3e /Master/texmf-dist/source/latex/l3kernel/l3tl.dtx | |
parent | 03b8dcfa3435f0265dfad4fd09aaab8f4ff9c617 (diff) |
l3 (15jul17)
git-svn-id: svn://tug.org/texlive/trunk@44813 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3tl.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3tl.dtx | 298 |
1 files changed, 135 insertions, 163 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx index e0124c53a60..82d13e8cb54 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx @@ -41,7 +41,7 @@ % }^^A % } % -% \date{Released 2017/05/29} +% \date{Released 2017/07/15} % % \maketitle % @@ -92,7 +92,7 @@ % \end{syntax} % Creates a new \meta{tl~var} or raises an error if the % name is already taken. The declaration is global. The -% \meta{tl~var} will initially be empty. +% \meta{tl~var} is initially empty. % \end{function} % % \begin{function}{\tl_const:Nn, \tl_const:Nx, \tl_const:cn, \tl_const:cx} @@ -101,8 +101,7 @@ % \end{syntax} % Creates a new constant \meta{tl~var} or raises an error % if the name is already taken. The value of the -% \meta{tl~var} will be set globally to the -% \meta{token list}. +% \meta{tl~var} is set globally to the \meta{token list}. % \end{function} % % \begin{function}{\tl_clear:N, \tl_clear:c, \tl_gclear:N, \tl_gclear:c} @@ -144,7 +143,7 @@ % \end{syntax} % Concatenates the content of \meta{tl~var_2} and \meta{tl~var_3} % together and saves the result in \meta{tl~var_1}. The \meta{tl~var_2} -% will be placed at the left side of the new token list. +% is placed at the left side of the new token list. % \end{function} % % \begin{function}[EXP, pTF, added=2012-03-03]{\tl_if_exist:N, \tl_if_exist:c} @@ -273,7 +272,7 @@ % \cs{tl_set:Nn} \cs{l_tmpa_tl} |{abbccd}| % \cs{tl_remove_all:Nn} \cs{l_tmpa_tl} |{bc}| % \end{quote} -% will result in \cs{l_tmpa_tl} containing \texttt{abcd}. +% results in \cs{l_tmpa_tl} containing \texttt{abcd}. % \end{function} % % \section{Reassigning token list category codes} @@ -299,7 +298,7 @@ % Sets \meta{tl~var} to contain \meta{tokens}, applying the category % code r\'{e}gime specified in the \meta{setup} before carrying out % the assignment. (Category codes applied to tokens not explicitly covered -% by the \meta{setup} will be those in force at the point of use of +% by the \meta{setup} are those in force at the point of use of % \cs{tl_set_rescan:Nnn}.) % This allows the \meta{tl~var} to contain material % with category codes other than those that apply when \meta{tokens} @@ -329,7 +328,7 @@ % Rescans \meta{tokens} applying the category code r\'{e}gime % specified in the \meta{setup}, and leaves the resulting tokens in % the input stream. (Category codes applied to tokens not explicitly covered -% by the \meta{setup} will be those in force at the point of use of +% by the \meta{setup} are those in force at the point of use of % \cs{tl_rescan:nn}.) % The \meta{setup} is run within a group and may % contain any valid input, although only changes in category codes @@ -475,7 +474,7 @@ % with each of the \meta{token list variable cases}. If the two % are equal (as described for \cs{tl_if_eq:NNTF}) % then the associated \meta{code} is left in the input -% stream. If any of the +% stream and other cases are discarded. If any of the % cases are matched, the \meta{true code} is also inserted into the % input stream (after the code for the appropriate case), while if none % match then the \meta{false code} is inserted. The function @@ -491,7 +490,7 @@ % \cs{tl_map_function:NN} \meta{tl~var} \meta{function} % \end{syntax} % Applies \meta{function} to every \meta{item} in the \meta{tl~var}. -% The \meta{function} will receive one argument for each iteration. +% The \meta{function} receives one argument for each iteration. % This may be a number of tokens if the \meta{item} was stored within % braces. Hence the \meta{function} should anticipate receiving % \texttt{n}-type arguments. See also \cs{tl_map_function:nN}. @@ -502,7 +501,7 @@ % \cs{tl_map_function:nN} \meta{token list} \meta{function} % \end{syntax} % Applies \meta{function} to every \meta{item} in the \meta{token list}, -% The \meta{function} will receive one argument for each iteration. +% The \meta{function} receives one argument for each iteration. % This may be a number of tokens if the \meta{item} was stored within % braces. Hence the \meta{function} should anticipate receiving % \texttt{n}-type arguments. See also \cs{tl_map_function:NN}. @@ -515,7 +514,7 @@ % \end{syntax} % Applies the \meta{inline function} to every \meta{item} stored within the % \meta{tl~var}. The \meta{inline function} should consist of code which -% will receive the \meta{item} as |#1|. One in line mapping can be nested +% receives the \meta{item} as |#1|. One in line mapping can be nested % inside another. See also \cs{tl_map_function:NN}. % \end{function} % @@ -525,7 +524,7 @@ % \end{syntax} % Applies the \meta{inline function} to every \meta{item} stored within the % \meta{token list}. The \meta{inline function} should consist of code which -% will receive the \meta{item} as |#1|. One in line mapping can be nested +% receives the \meta{item} as |#1|. One in line mapping can be nested % inside another. See also \cs{tl_map_function:nN}. % \end{function} % @@ -536,7 +535,7 @@ % \end{syntax} % Applies the \meta{function} to every \meta{item} stored % within the \meta{tl~var}. The \meta{function} should consist of code -% which will receive the \meta{item} stored in the \meta{variable}. +% which receives the \meta{item} stored in the \meta{variable}. % One variable mapping can be nested inside another. See also % \cs{tl_map_inline:Nn}. % \end{function} @@ -547,7 +546,7 @@ % \end{syntax} % Applies the \meta{function} to every \meta{item} stored % within the \meta{token list}. The \meta{function} should consist of code -% which will receive the \meta{item} stored in the \meta{variable}. +% which receives the \meta{item} stored in the \meta{variable}. % One variable mapping can be nested inside another. See also % \cs{tl_map_inline:nn}. % \end{function} @@ -558,7 +557,7 @@ % \end{syntax} % Used to terminate a \cs[no-index]{tl_map_\ldots} function before all % entries in the \meta{token list variable} have been processed. This -% will normally take place within a conditional statement, for example +% normally takes place within a conditional statement, for example % \begin{verbatim} % \tl_map_inline:Nn \l_my_tl % { @@ -567,13 +566,13 @@ % } % \end{verbatim} % See also \cs{tl_map_break:n}. -% Use outside of a \cs[no-index]{tl_map_\ldots} scenario will lead to low +% Use outside of a \cs[no-index]{tl_map_\ldots} scenario leads to low % level \TeX{} errors. % \begin{texnote} % When the mapping is broken, additional tokens may be inserted by the % internal macro \cs{__prg_break_point:Nn} before the \meta{tokens} are % inserted into the input stream. -% This will depend on the design of the mapping function. +% This depends on the design of the mapping function. % \end{texnote} % \end{function} % @@ -583,8 +582,8 @@ % \end{syntax} % Used to terminate a \cs[no-index]{tl_map_\ldots} function before all % entries in the \meta{token list variable} have been processed, inserting -% the \meta{tokens} after the mapping has ended. This will -% normally take place within a conditional statement, for example +% the \meta{tokens} after the mapping has ended. This +% normally takes place within a conditional statement, for example % \begin{verbatim} % \tl_map_inline:Nn \l_my_tl % { @@ -593,13 +592,13 @@ % % Do something useful % } % \end{verbatim} -% Use outside of a \cs[no-index]{tl_map_\ldots} scenario will lead to low +% Use outside of a \cs[no-index]{tl_map_\ldots} scenario leads to low % level \TeX{} errors. % \begin{texnote} % When the mapping is broken, additional tokens may be inserted by the % internal macro \cs{__prg_break_point:Nn} before the \meta{tokens} are % inserted into the input stream. -% This will depend on the design of the mapping function. +% This depends on the design of the mapping function. % \end{texnote} % \end{function} % @@ -657,7 +656,7 @@ % \cs{tl_use:N} \meta{tl~var} % \end{syntax} % Recovers the content of a \meta{tl~var} and places it -% directly in the input stream. An error will be raised if the variable +% directly in the input stream. An error is raised if the variable % does not exist or if it is invalid. Note that it is possible to use % a \meta{tl~var} directly without an accessor function. % \end{function} @@ -671,8 +670,8 @@ % \end{syntax} % Counts the number of \meta{items} in \meta{tokens} and leaves this % information in the input stream. Unbraced tokens count as one -% element as do each token group (|{|\ldots|}|). This process will -% ignore any unprotected spaces within \meta{tokens}. See also +% element as do each token group (|{|\ldots|}|). This process +% ignores any unprotected spaces within \meta{tokens}. See also % \cs{tl_count:N}. This function requires three expansions, % giving an \meta{integer denotation}. % \end{function} @@ -684,7 +683,7 @@ % Counts the number of token groups in the \meta{tl~var} % and leaves this information in the input stream. Unbraced tokens % count as one element as do each token group (|{|\ldots|}|). This -% process will ignore any unprotected spaces within the \meta{tl~var}. +% process ignores any unprotected spaces within the \meta{tl~var}. % See also \cs{tl_count:n}. This function requires three expansions, % giving an \meta{integer denotation}. % \end{function} @@ -697,7 +696,7 @@ % Reverses the order of the \meta{items} in the \meta{token list}, % so that \meta{item_1}\meta{item_2}\meta{item_3} \ldots \meta{item_n} % becomes \meta{item_n}\ldots \meta{item_3}\meta{item_2}\meta{item_1}. -% This process will preserve unprotected space within the +% This process preserves unprotected space within the % \meta{token list}. Tokens are not reversed within braced token % groups, which keep their outer set of braces. % In situations where performance is important, @@ -705,7 +704,7 @@ % See also \cs{tl_reverse:N}. % \begin{texnote} % The result is returned within \tn{unexpanded}, which means that the token -% list will not expand further when appearing in an \texttt{x}-type +% list does not expand further when appearing in an \texttt{x}-type % argument expansion. % \end{texnote} % \end{function} @@ -718,7 +717,7 @@ % Reverses the order of the \meta{items} stored in \meta{tl~var}, so % that \meta{item_1}\meta{item_2}\meta{item_3} \ldots \meta{item_n} % becomes \meta{item_n}\ldots \meta{item_3}\meta{item_2}\meta{item_1}. -% This process will preserve unprotected spaces within the +% This process preserves unprotected spaces within the % \meta{token list variable}. Braced token groups are copied without % reversing the order of tokens, but keep the outer set of braces. % See also \cs{tl_reverse:n}, and, for improved performance, @@ -732,7 +731,7 @@ % Reverses the order of the \meta{items} stored in \meta{tl~var}, % so that \Arg{item_1}\Arg{item_2}\Arg{item_3} \ldots \Arg{item_n} % becomes \Arg{item_n} \ldots{} \Arg{item_3}\Arg{item_2}\Arg{item_1}. -% This process will remove any unprotected space within the +% This process removes any unprotected space within the % \meta{token list}. Braced token groups are copied without % reversing the order of tokens, and keep the outer set of braces. % Items which are initially not braced are copied with braces in @@ -740,7 +739,7 @@ % consider the slower function \cs{tl_reverse:n}. % \begin{texnote} % The result is returned within \tn{unexpanded}, which means that the token -% list will not expand further when appearing in an \texttt{x}-type +% list does not expand further when appearing in an \texttt{x}-type % argument expansion. % \end{texnote} % \end{function} @@ -756,7 +755,7 @@ % stream. % \begin{texnote} % The result is returned within \tn{unexpanded}, which means that the token -% list will not expand further when appearing in an \texttt{x}-type +% list does not expand further when appearing in an \texttt{x}-type % argument expansion. % \end{texnote} % \end{function} @@ -799,7 +798,7 @@ % described in Section~\ref{sec:l3sort:mech}. % \begin{texnote} % The result is returned within \cs{exp_not:n}, which means that the -% token list will not expand further when appearing in an +% token list does not expand further when appearing in an % \texttt{x}-type argument expansion. % \end{texnote} % \end{function} @@ -826,18 +825,18 @@ % \begin{verbatim} % \tl_head:n { ~ abc } % \end{verbatim} -% will both leave |a| in the input stream. If the \enquote{head} is a -% brace group, rather than a single token, the braces will be removed, and +% both leave |a| in the input stream. If the \enquote{head} is a +% brace group, rather than a single token, the braces are removed, and % so % \begin{verbatim} % \tl_head:n { ~ { ~ ab } c } % \end{verbatim} % yields \verb*| ab|. -% A blank \meta{token list} (see \cs{tl_if_blank:nTF}) will result in +% A blank \meta{token list} (see \cs{tl_if_blank:nTF}) results in % \cs{tl_head:n} leaving nothing in the input stream. % \begin{texnote} % The result is returned within \cs{exp_not:n}, which means that the token -% list will not expand further when appearing in an \texttt{x}-type +% list does not expand further when appearing in an \texttt{x}-type % argument expansion. % \end{texnote} % \end{function} @@ -852,7 +851,7 @@ % (explicit tokens with character code~$32$ and category code~$10$) % are discarded. % A blank \meta{token list} (which consists only of space characters) -% will result in a low-level \TeX{} error, which may be avoided by the +% results in a low-level \TeX{} error, which may be avoided by the % inclusion of an empty group in the input (as shown), without the need % for an explicit test. Alternatively, \cs{tl_if_blank:nF} may be used to % avoid using the function with a \enquote{blank} argument. @@ -877,12 +876,12 @@ % \begin{verbatim} % \tl_tail:n { ~ a ~ {bc} d } % \end{verbatim} -% will both leave \verb*| {bc}d| in the input stream. A blank -% \meta{token list} (see \cs{tl_if_blank:nTF}) will result +% both leave \verb*| {bc}d| in the input stream. A blank +% \meta{token list} (see \cs{tl_if_blank:nTF}) results % in \cs{tl_tail:n} leaving nothing in the input stream. % \begin{texnote} % The result is returned within \cs{exp_not:n}, which means that the -% token list will not expand further when appearing in an \texttt{x}-type +% token list does not expand further when appearing in an \texttt{x}-type % argument expansion. % \end{texnote} % \end{function} @@ -895,7 +894,7 @@ % \end{syntax} % Tests if the first \meta{token} in the \meta{token list} has the % same category code as the \meta{test token}. In the case where the -% \meta{token list} is empty, the test will always be \texttt{false}. +% \meta{token list} is empty, the test is always \texttt{false}. % \end{function} % % \begin{function}[updated = 2012-07-09, EXP, pTF] @@ -907,7 +906,7 @@ % \end{syntax} % Tests if the first \meta{token} in the \meta{token list} has the % same character code as the \meta{test token}. In the case where the -% \meta{token list} is empty, the test will always be \texttt{false}. +% \meta{token list} is empty, the test is always \texttt{false}. % \end{function} % % \begin{function}[updated = 2012-07-09, EXP, pTF]{\tl_if_head_eq_meaning:nN} @@ -918,7 +917,7 @@ % \end{syntax} % Tests if the first \meta{token} in the \meta{token list} has the % same meaning as the \meta{test token}. In the case where -% \meta{token list} is empty, the test will always be \texttt{false}. +% \meta{token list} is empty, the test is always \texttt{false}. % \end{function} % % \begin{function}[added = 2012-07-08, EXP, pTF]{\tl_if_head_is_group:n} @@ -976,7 +975,7 @@ % \cs{tl_item:nn} \Arg{token list} \Arg{integer expression} % \end{syntax} % Indexing items in the \meta{token list} from~$1$ on the left, this -% function will evaluate the \meta{integer expression} and leave the +% function evaluates the \meta{integer expression} and leaves the % appropriate item from the \meta{token list} in the input stream. % If the \meta{integer expression} is negative, indexing occurs from % the right of the token list, starting at $-1$ for the right-most item. @@ -984,7 +983,7 @@ % \begin{texnote} % The result is returned within the \tn{unexpanded} % primitive (\cs{exp_not:n}), which means that the \meta{item} -% will not expand further when appearing in an \texttt{x}-type +% does not expand further when appearing in an \texttt{x}-type % argument expansion. % \end{texnote} % \end{function} @@ -1126,7 +1125,7 @@ % \begin{macro}{\tl_clear:N, \tl_clear:c} % \begin{macro}{\tl_gclear:N, \tl_gclear:c} % Clearing a token list variable means setting it to an empty value. -% Error checking will be sorted out by the parent function. +% Error checking is sorted out by the parent function. % \begin{macrocode} \cs_new_protected:Npn \tl_clear:N #1 { \tl_set_eq:NN #1 \c_empty_tl } @@ -1141,7 +1140,7 @@ % \begin{macro}{\tl_clear_new:N, \tl_clear_new:c} % \begin{macro}{\tl_gclear_new:N, \tl_gclear_new:c} % Clearing a token list variable means setting it to an empty value. -% Error checking will be sorted out by the parent function. +% Error checking is sorted out by the parent function. % \begin{macrocode} \cs_new_protected:Npn \tl_clear_new:N #1 { \tl_if_exist:NTF #1 { \tl_clear:N #1 } { \tl_new:N #1 } } @@ -1155,26 +1154,54 @@ % % \begin{macro}{\tl_set_eq:NN, \tl_set_eq:Nc, \tl_set_eq:cN, \tl_set_eq:cc} % \begin{macro}{\tl_gset_eq:NN, \tl_gset_eq:Nc, \tl_gset_eq:cN, \tl_gset_eq:cc} -% For setting token list variables equal to each other. +% For setting token list variables equal to each other. When checking +% is turned on, make sure both variables exist. % \begin{macrocode} -\cs_new_eq:NN \tl_set_eq:NN \cs_set_eq:NN -\cs_new_eq:NN \tl_set_eq:cN \cs_set_eq:cN -\cs_new_eq:NN \tl_set_eq:Nc \cs_set_eq:Nc -\cs_new_eq:NN \tl_set_eq:cc \cs_set_eq:cc -\cs_new_eq:NN \tl_gset_eq:NN \cs_gset_eq:NN -\cs_new_eq:NN \tl_gset_eq:cN \cs_gset_eq:cN -\cs_new_eq:NN \tl_gset_eq:Nc \cs_gset_eq:Nc -\cs_new_eq:NN \tl_gset_eq:cc \cs_gset_eq:cc +\tex_ifodd:D \l@expl@enable@debug@bool + \cs_new_protected:Npn \tl_set_eq:NN #1#2 + { + \__chk_if_exist_var:N #1 + \__chk_if_exist_var:N #2 + \cs_set_eq:NN #1 #2 + } + \cs_new_protected:Npn \tl_gset_eq:NN #1#2 + { + \__chk_if_exist_var:N #1 + \__chk_if_exist_var:N #2 + \cs_gset_eq:NN #1 #2 + } +\else: + \cs_new_eq:NN \tl_set_eq:NN \cs_set_eq:NN + \cs_new_eq:NN \tl_gset_eq:NN \cs_gset_eq:NN +\fi: +\cs_generate_variant:Nn \tl_set_eq:NN { cN, Nc, cc } +\cs_generate_variant:Nn \tl_gset_eq:NN { cN, Nc, cc } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\tl_concat:NNN, \tl_concat:ccc} % \begin{macro}{\tl_gconcat:NNN, \tl_gconcat:ccc} -% Concatenating token lists is easy. +% Concatenating token lists is easy. When checking is turned on, all +% three arguments must be checked: a token list |#2| or |#3| equal to +% \cs{scan_stop:} would lead to problems later on. % \begin{macrocode} +\__debug_patch:nnNw + { + \__chk_if_exist_var:N #1 + \__chk_if_exist_var:N #2 + \__chk_if_exist_var:N #3 + } + { } \cs_new_protected:Npn \tl_concat:NNN #1#2#3 { \tl_set:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } } +\__debug_patch:nnNw + { + \__chk_if_exist_var:N #1 + \__chk_if_exist_var:N #2 + \__chk_if_exist_var:N #3 + } + { } \cs_new_protected:Npn \tl_gconcat:NNN #1#2#3 { \tl_gset:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } } \cs_generate_variant:Nn \tl_concat:NNN { ccc } @@ -1224,18 +1251,26 @@ % By using \cs{exp_not:n} token list variables can contain |#| tokens, % which makes the token list registers provided by \TeX{} % more or less redundant. The \cs{tl_set:No} version is done -% \enquote{by hand} as it is used quite a lot. +% \enquote{by hand} as it is used quite a lot. Each definition is +% prefixed by a call to \cs{__debug_patch:nnNw} which adds an +% existence check to the definition. % \begin{macrocode} +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_set:Nn #1#2 { \cs_set_nopar:Npx #1 { \exp_not:n {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_set:No #1#2 { \cs_set_nopar:Npx #1 { \exp_not:o {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_set:Nx #1#2 { \cs_set_nopar:Npx #1 {#2} } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gset:Nn #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:n {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gset:No #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:o {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gset:Nx #1#2 { \cs_gset_nopar:Npx #1 {#2} } \cs_generate_variant:Nn \tl_set:Nn { NV , Nv , Nf } @@ -1260,20 +1295,28 @@ % } % Adding to the left is done directly to gain a little performance. % \begin{macrocode} +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_left:Nn #1#2 { \cs_set_nopar:Npx #1 { \exp_not:n {#2} \exp_not:o #1 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_left:NV #1#2 { \cs_set_nopar:Npx #1 { \exp_not:V #2 \exp_not:o #1 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_left:No #1#2 { \cs_set_nopar:Npx #1 { \exp_not:o {#2} \exp_not:o #1 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_left:Nx #1#2 { \cs_set_nopar:Npx #1 { #2 \exp_not:o #1 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_left:Nn #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:n {#2} \exp_not:o #1 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_left:NV #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:V #2 \exp_not:o #1 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_left:No #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:o {#2} \exp_not:o #1 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_left:Nx #1#2 { \cs_gset_nopar:Npx #1 { #2 \exp_not:o {#1} } } \cs_generate_variant:Nn \tl_put_left:Nn { c } @@ -1302,20 +1345,28 @@ % } % The same on the right. % \begin{macrocode} +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_right:Nn #1#2 { \cs_set_nopar:Npx #1 { \exp_not:o #1 \exp_not:n {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_right:NV #1#2 { \cs_set_nopar:Npx #1 { \exp_not:o #1 \exp_not:V #2 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_right:No #1#2 { \cs_set_nopar:Npx #1 { \exp_not:o #1 \exp_not:o {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_put_right:Nx #1#2 { \cs_set_nopar:Npx #1 { \exp_not:o #1 #2 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_right:Nn #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:o #1 \exp_not:n {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_right:NV #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:o #1 \exp_not:V #2 } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_right:No #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:o #1 \exp_not:o {#2} } } +\__debug_patch:nnNw { \__chk_if_exist_var:N #1 } { } \cs_new_protected:Npn \tl_gput_right:Nx #1#2 { \cs_gset_nopar:Npx #1 { \exp_not:o {#1} #2 } } \cs_generate_variant:Nn \tl_put_right:Nn { c } @@ -1330,85 +1381,6 @@ % \end{macro} % \end{macro} % -% When used as a package, there is an option to be picky and to -% check definitions exist. This part of the process is done now, so that -% variable types based on |tl| (for example |clist|, |seq| and |prop|) will -% inherit the appropriate definitions. -% No \cs[no-index]{tl_map_\ldots} yet as the mechanisms are not fully in place. Thus -% instead do a more low level set up for a mapping, as in \pkg{l3basics}. -% \begin{macrocode} -%<*package> -\tex_ifodd:D \l@expl@check@declarations@bool - \cs_set_protected:Npn \__cs_tmp:w #1 - { - \if_meaning:w \q_recursion_tail #1 - \exp_after:wN \use_none_delimit_by_q_recursion_stop:w - \fi: - \use:x - { - \cs_set_protected:Npn #1 \exp_not:n { ##1 ##2 } - { - \__chk_if_exist_var:N \exp_not:n {##1} - \exp_not:o { #1 {##1} {##2} } - } - } - \__cs_tmp:w - } - \__cs_tmp:w - \tl_set:Nn \tl_set:No \tl_set:Nx - \tl_gset:Nn \tl_gset:No \tl_gset:Nx - \tl_put_left:Nn \tl_put_left:NV - \tl_put_left:No \tl_put_left:Nx - \tl_gput_left:Nn \tl_gput_left:NV - \tl_gput_left:No \tl_gput_left:Nx - \tl_put_right:Nn \tl_put_right:NV - \tl_put_right:No \tl_put_right:Nx - \tl_gput_right:Nn \tl_gput_right:NV - \tl_gput_right:No \tl_gput_right:Nx - \q_recursion_tail \q_recursion_stop -%</package> -% \end{macrocode} -% The two \texttt{set_eq} functions are done by hand as the internals there -% are a bit different. -% \begin{macrocode} -%<*package> - \cs_set_protected:Npn \tl_set_eq:NN #1#2 - { - \__chk_if_exist_var:N #1 - \__chk_if_exist_var:N #2 - \cs_set_eq:NN #1 #2 - } - \cs_set_protected:Npn \tl_gset_eq:NN #1#2 - { - \__chk_if_exist_var:N #1 - \__chk_if_exist_var:N #2 - \cs_gset_eq:NN #1 #2 - } -%</package> -% \end{macrocode} -% There is also a need to check all three arguments of the -% \texttt{concat} functions: a token list |#2| or |#3| equal to -% \cs{scan_stop:} would lead to problems later on. -% \begin{macrocode} -%<*package> - \cs_set_protected:Npn \tl_concat:NNN #1#2#3 - { - \__chk_if_exist_var:N #1 - \__chk_if_exist_var:N #2 - \__chk_if_exist_var:N #3 - \tl_set:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } - } - \cs_set_protected:Npn \tl_gconcat:NNN #1#2#3 - { - \__chk_if_exist_var:N #1 - \__chk_if_exist_var:N #2 - \__chk_if_exist_var:N #3 - \tl_gset:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } - } -\tex_fi:D -%</package> -% \end{macrocode} -% % \subsection{Reassigning token list category codes} % % \begin{variable}{\c_@@_rescan_marker_tl} @@ -1452,7 +1424,7 @@ % The standard solution is to use an \texttt{x}-expanding assignment % and set \tn{everyeof} to \cs{exp_not:N} to suppress the error at % the end of the file. Since the rescanned tokens should not be -% expanded, they will be taken as a delimited argument of an +% expanded, they are taken as a delimited argument of an % auxiliary which wraps them in \cs{exp_not:n} (in fact % \cs{exp_not:o}, as there is a \cs{prg_do_nothing:} to avoid losing % braces). The delimiter cannot appear within the rescanned token @@ -1536,8 +1508,8 @@ % ignored at the beginning of lines, and spaces and tabs (character % code $32$ and $9$) are ignored at the end of lines. % -% For a single line, no \tn{endlinechar} should be added, so it will -% be set to $-1$, and spaces should not be removed. +% For a single line, no \tn{endlinechar} should be added, so it is +% set to $-1$, and spaces should not be removed. % % Trailing spaces and tabs are a difficult matter, as \TeX{} removes % these at a very low level. The only way to preserve them is to @@ -1681,7 +1653,7 @@ % \@@_replace_wrap:w, % } % To implement the actual replacement auxiliary -% \cs{@@_replace_auxii:nNNNnn} we will need a \meta{delimiter} with +% \cs{@@_replace_auxii:nNNNnn} we need a \meta{delimiter} with % the following properties: % \begin{itemize} % \item all occurrences of the \meta{pattern}~|#6| in @@ -1715,7 +1687,7 @@ % at most $O(n^{3/2})$. Bear in mind that these upper bounds are % reached only in very contrived scenarios: we include the case % \enquote{\meta{A}} in the list of delimiters to try, so that the -% \meta{delimiter} will simply be \cs{q_mark} in the most common +% \meta{delimiter} is simply \cs{q_mark} in the most common % situation where neither the \meta{token list} nor the \meta{pattern} % contains \cs{q_mark}. % @@ -1920,7 +1892,7 @@ % \end{macro} % % \begin{macro}[pTF]{\tl_if_empty:n, \tl_if_empty:V} -% Convert the argument to a string: this will be empty if and only if +% Convert the argument to a string: this is empty if and only if % the argument is. Then |\if_meaning:w \q_nil ... \q_nil| is % \texttt{true} if and only if the string |...| is empty. % It could be tempting to use |\if_meaning:w \q_nil #1 \q_nil| directly. @@ -2082,10 +2054,10 @@ % there are no odd category codes. An earlier version would compare % the result to a single~|?| using string comparison, but the Lua call % is slow in \LuaTeX{}. Instead, \cs{@@_if_single:nnw} picks the -% second token in front of it. If |#1| is empty, this token will be +% second token in front of it. If |#1| is empty, this token is % the trailing~|?| and the catcode test yields \texttt{false}. If -% |#1| has a single item, the token will be~|^| and the catcode test -% yields \texttt{true}. Otherwise, it will be one of the characters +% |#1| has a single item, the token is~|^| and the catcode test +% yields \texttt{true}. Otherwise, it is one of the characters % resulting from \cs{tl_to_str:n}, and the catcode test yields % \texttt{false}. Note that \cs{if_catcode:w} takes care of the % expansions, and that \cs{tl_to_str:n} (the \tn{detokenize} @@ -2115,7 +2087,7 @@ % using a known number of expansion steps (two), and without % needing to use an explicit \enquote{end of recursion} marker. % That is achieved by using the test input as the final case, -% as this will always be true. The trick is then to tidy up +% as this is always true. The trick is then to tidy up % the output such that the appropriate case code plus either % the \texttt{true} or \texttt{false} branch code is inserted. % \begin{macrocode} @@ -2153,14 +2125,14 @@ \cs_generate_variant:Nn \tl_case:NnTF { c } % \end{macrocode} % To tidy up the recursion, there are two outcomes. If there was a hit to -% one of the cases searched for, then |#1| will be the code to insert, -% |#2| will be the \emph{next} case to check on and |#3| will be all of -% the rest of the cases code. That means that |#4| will be the \texttt{true} -% branch code, and |#5| will be tidy up the spare \cs{q_mark} and the +% one of the cases searched for, then |#1| is the code to insert, +% |#2| is the \emph{next} case to check on and |#3| is all of +% the rest of the cases code. That means that |#4| is the \texttt{true} +% branch code, and |#5| tidies up the spare \cs{q_mark} and the % \texttt{false} branch. On the other hand, if none of the cases matched % then we arrive here using the \enquote{termination} case of comparing -% the search with itself. That means that |#1| will be empty, |#2| will be -% the first \cs{q_mark} and so |#4| will be the \texttt{false} code (the +% the search with itself. That means that |#1| is empty, |#2| is +% the first \cs{q_mark} and so |#4| is the \texttt{false} code (the % \texttt{true} code is mopped up by |#3|). % \begin{macrocode} \cs_new:Npn \__prg_case_end:nw #1#2#3 \q_mark #4#5 \q_stop @@ -2180,7 +2152,7 @@ % \begin{macro}[aux]{\@@_map_function:Nn} % Expandable loop macro for token lists. These have the advantage of not % needing to test if the argument is empty, because if it is, the stop -% marker will be read immediately and the loop terminated. +% marker is read immediately and the loop terminated. % \begin{macrocode} \cs_new:Npn \tl_map_function:nN #1#2 { @@ -2284,7 +2256,7 @@ % \end{macro} % % \begin{macro}{\tl_use:N, \tl_use:c} -% Token lists which are simply not defined will give a clear \TeX{} +% Token lists which are simply not defined give a clear \TeX{} % error here. No such luck for ones equal to \cs{scan_stop:} so % instead a test is made and if there is an issue an error is forced. % \begin{macrocode} @@ -2365,10 +2337,10 @@ % Trimming spaces from around the input is deferred to an internal % function whose first argument is the token list to trim, augmented % by an initial \cs{q_mark}, and whose second argument is a -% \meta{continuation}, which will receive as a braced argument +% \meta{continuation}, which receives as a braced argument % \cs{use_none:n} \cs{q_mark} \meta{trimmed token list}. In the case % at hand, we take \cs{exp_not:o} as our continuation, so that space -% trimming will behave correctly within an \texttt{x}-type expansion. +% trimming behaves correctly within an \texttt{x}-type expansion. % \begin{macrocode} \cs_new:Npn \tl_trim_spaces:n #1 { \@@_trim_spaces:nn { \q_mark #1 } \exp_not:o } @@ -2606,7 +2578,7 @@ % \begin{macro}[aux]{\@@_head_auxi:nw, \@@_head_auxii:n} % \begin{macro}{\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 will always strip braces, which +% 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 % 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. @@ -2643,14 +2615,14 @@ \cs_new:Npn \tl_head:w #1#2 \q_stop {#1} \cs_new:Npn \tl_head:N { \exp_args:No \tl_head:n } % \end{macrocode} -% To corrected leave the tail of a token list, it's important \emph{not} to +% To correctly leave the tail of a token list, it's important \emph{not} to % absorb any of the tail part as an argument. For example, the simple % definition % \begin{verbatim} % \cs_new:Npn \tl_tail:n #1 { \tl_tail:w #1 \q_stop } % \cs_new:Npn \tl_tail:w #1#2 \q_stop % \end{verbatim} -% will give the wrong result for |\tl_tail:n { a { bc } }| (the braces will +% would give the wrong result for |\tl_tail:n { a { bc } }| (the braces would % be stripped). Thus the only safe way to proceed is to first check that % there is an item to grab (\emph{i.e.}~that the argument is not blank) and % assuming there is to dispose of the first item. As with \cs{tl_head:n}, @@ -2695,8 +2667,8 @@ % token lists to the \texttt{true} branch of this test). In those % cases, the first token is a character, and since we only care about % its character code, we can use \cs{str_head:n} to access it (this -% works even if it is a space character). An empty argument will -% result in \cs{tl_head:w} leaving two tokens: |?| which is taken in +% works even if it is a space character). An empty argument +% results in \cs{tl_head:w} leaving two tokens: |?| which is taken in % the \cs{if_charcode:w} test, and \cs{use_none:nn}, which ensures % that \cs{prg_return_false:} is returned regardless of whether the % charcode test was \texttt{true} or \texttt{false}. |