[latex3-commits] [latex3/latex3] main: Move \seq_set_item:Nnn to stable (866ba55e5)
github at latex-project.org
github at latex-project.org
Wed May 10 21:55:18 CEST 2023
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/866ba55e5a76802f504165123e1b228ee0550f61
>---------------------------------------------------------------
commit 866ba55e5a76802f504165123e1b228ee0550f61
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed May 10 20:52:53 2023 +0100
Move \seq_set_item:Nnn to stable
>---------------------------------------------------------------
866ba55e5a76802f504165123e1b228ee0550f61
l3kernel/CHANGELOG.md | 3 ++
l3kernel/l3candidates.dtx | 134 ----------------------------------------------
l3kernel/l3msg.dtx | 9 ++++
l3kernel/l3seq.dtx | 125 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 137 insertions(+), 134 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 302ed7027..fd02e7e05 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+### Changed
+- Moved `\seq_set_item:Nnn` to stable status
+
### Removed
- Experimental function `\seq_pop_item:NnN` from `l3candidates`
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index bd3ee0fc8..3c8239066 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -119,24 +119,6 @@
% \end{texnote}
% \end{function}
%
-% \begin{function}[added = 2021-04-29, noTF]
-% {\seq_set_item:Nnn, \seq_set_item:cnn, \seq_gset_item:Nnn, \seq_gset_item:cnn}
-% \begin{syntax}
-% \cs{seq_set_item:Nnn} \meta{seq~var} \Arg{int expr} \Arg{item}
-% \cs{seq_set_item:NnnTF} \meta{seq~var} \Arg{int expr} \Arg{item} \Arg{true code} \Arg{false code}
-% \end{syntax}
-% Removes the item of \meta{sequence} at the position given by
-% evaluating the \meta{int expr} and replaces it by
-% \meta{item}. Items are indexed from $1$ on the left/top of the
-% \meta{sequence}, or from $-1$ on the right/bottom. If the
-% \meta{int expr} is zero or is larger (in absolute value)
-% than the number of items in the sequence, the \meta{sequence} is not
-% modified. In these cases, \cs{seq_set_item:Nnn} raises an error
-% while \cs{seq_set_item:NnnTF} runs the \meta{false code}. In cases
-% where the assignment was successful, \meta{true code} is run
-% afterwards.
-% \end{function}
-%
% \section{Additions to \pkg{l3tl}}
%
% \begin{function}[added = 2018-04-01]{\tl_build_begin:N, \tl_build_gbegin:N}
@@ -294,122 +276,6 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\@@_int_eval:w}
-% Useful to more quickly go through items.
-% \begin{macrocode}
-\cs_new_eq:NN \@@_int_eval:w \tex_numexpr:D
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}[noTF]{\seq_set_item:Nnn, \seq_set_item:cnn, \seq_gset_item:Nnn, \seq_gset_item:cnn}
-% \begin{macro}{\@@_set_item:NnnNN, \@@_set_item:nnNNNN, \@@_set_item_false:nnNNNN, \@@_set_item:nNnnNNNN}
-% \begin{macro}[rEXP]{\@@_set_item:wn, \@@_set_item_end:w}
-% The conditionals are distinguished from the |Nnn| versions by the
-% last argument \cs{use_ii:nn} vs \cs{use_i:nn}.
-% \begin{macrocode}
-\cs_new_protected:Npn \seq_set_item:Nnn #1#2#3
- { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_set:Nx \use_i:nn }
-\cs_new_protected:Npn \seq_gset_item:Nnn #1#2#3
- { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_gset:Nx \use_i:nn }
-\cs_generate_variant:Nn \seq_set_item:Nnn { c }
-\cs_generate_variant:Nn \seq_gset_item:Nnn { c }
-\prg_new_protected_conditional:Npnn \seq_set_item:Nnn #1#2#3 { TF , T , F }
- { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_set:Nx \use_ii:nn }
-\prg_new_protected_conditional:Npnn \seq_gset_item:Nnn #1#2#3 { TF , T , F }
- { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_gset:Nx \use_ii:nn }
-\prg_generate_conditional_variant:Nnn \seq_set_item:Nnn { c } { TF , T , F }
-\prg_generate_conditional_variant:Nnn \seq_gset_item:Nnn { c } { TF , T , F }
-% \end{macrocode}
-% Save the item to be stored and evaluate the position and the sequence
-% length only once. Then depending on the sign of the position, check
-% that it is not bigger than the length (in absolute value) nor zero.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_set_item:NnnNN #1#2#3
- {
- \tl_set:Nn \l_@@_internal_a_tl { \@@_item:n {#3} }
- \exp_args:Nff \@@_set_item:nnNNNN
- { \int_eval:n {#2} } { \seq_count:N #1 } #1 \use_none:nn
- }
-\cs_new_protected:Npn \@@_set_item:nnNNNN #1#2
- {
- \int_compare:nNnTF {#1} > 0
- { \int_compare:nNnF {#1} > {#2} { \@@_set_item:nNnnNNNN { #1 - 1 } } }
- {
- \int_compare:nNnF {#1} < {-#2}
- {
- \int_compare:nNnF {#1} = 0
- { \@@_set_item:nNnnNNNN { #2 + #1 } }
- }
- }
- \@@_set_item_false:nnNNNN {#1} {#2}
- }
-% \end{macrocode}
-% If the position is not ok, \cs{@@_set_item_false:nnNNNN} calls an
-% error or returns \texttt{false} (depending on the \cs{use_i:nn} vs
-% \cs{use_ii:nn} argument mentioned above).
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_set_item_false:nnNNNN #1#2#3#4#5#6
- {
- #6
- {
- \msg_error:nnxxx { seq } { item-too-large }
- { \token_to_str:N #3 } {#2} {#1}
- }
- { \prg_return_false: }
- }
-\msg_new:nnnn { seq } { item-too-large }
- { Sequence~'#1'~does~not~have~an~item~#3 }
- {
- An~attempt~was~made~to~push~or~pop~the~item~at~position~#3~
- of~'#1',~but~this~
- \int_compare:nTF { #3 = 0 }
- { position~does~not~exist. }
- { sequence~only~has~#2~item \int_compare:nF { #2 = 1 } {s}. }
- }
-% \end{macrocode}
-% If the position is ok, \cs{@@_set_item:nNnnNNNN} makes the assignment
-% and returns \texttt{true} (in the case of conditionnals). Here |#1|
-% is an integer expression (position minus one), it needs to be
-% evaluated. The sequence |#5| starts with \cs{s_@@} (even if empty),
-% which stops the integer expression and is absorbed by it. The
-% \cs{if_meaning:w} test is slightly faster than an integer test (but
-% only works when testing against zero, hence the offset we chose in
-% the position). When we are done skipping items, insert the saved
-% item \cs{l_@@_internal_a_tl}. For |put| functions the last argument
-% of \cs{@@_set_item_end:w} is \cs{use_none:nn} and it absorbs the
-% item |#2| that we are removing: this is only useful for the |pop|
-% functions.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_set_item:nNnnNNNN #1#2#3#4#5#6#7#8
- {
- #7 #5
- {
- \s_@@
- \exp_after:wN \@@_set_item:wn
- \int_value:w \@@_int_eval:w #1
- #5 \s_@@_stop #6
- }
- #8 { } { \prg_return_true: }
- }
-\cs_new:Npn \@@_set_item:wn #1 \@@_item:n #2
- {
- \if_meaning:w 0 #1 \@@_set_item_end:w \fi:
- \exp_not:n { \@@_item:n {#2} }
- \exp_after:wN \@@_set_item:wn
- \int_value:w \@@_int_eval:w #1 - 1 \s_@@
- }
-\cs_new:Npn \@@_set_item_end:w #1 \exp_not:n #2 #3 \s_@@ #4 \s_@@_stop #5
- {
- #1
- \exp_not:o \l_@@_internal_a_tl
- \exp_not:n {#4}
- #5 #2
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
% \subsection{Additions to \pkg{l3tl}}
%
% \subsubsection{Building a token list}
diff --git a/l3kernel/l3msg.dtx b/l3kernel/l3msg.dtx
index f2705cf8b..e5a9b60c7 100644
--- a/l3kernel/l3msg.dtx
+++ b/l3kernel/l3msg.dtx
@@ -1991,6 +1991,15 @@
LaTeX~has~been~asked~to~create~a~new~scan~mark~'#1'~
but~this~name~has~already~been~used~for~a~scan~mark.
}
+\msg_new:nnnn { seq } { item-too-large }
+ { Sequence~'#1'~does~not~have~an~item~#3 }
+ {
+ An~attempt~was~made~to~push~or~pop~the~item~at~position~#3~
+ of~'#1',~but~this~
+ \int_compare:nTF { #3 = 0 }
+ { position~does~not~exist. }
+ { sequence~only~has~#2~item \int_compare:nF { #2 = 1 } {s}. }
+ }
\msg_new:nnnn { seq } { shuffle-too-large }
{ The~sequence~#1~is~too~long~to~be~shuffled~by~TeX. }
{
diff --git a/l3kernel/l3seq.dtx b/l3kernel/l3seq.dtx
index e4aeffa83..7c62b8c36 100644
--- a/l3kernel/l3seq.dtx
+++ b/l3kernel/l3seq.dtx
@@ -474,6 +474,24 @@
% \cs{tl_if_eq:nnTF}.
% \end{function}
%
+% \begin{function}[added = 2021-04-29, noTF]
+% {\seq_set_item:Nnn, \seq_set_item:cnn, \seq_gset_item:Nnn, \seq_gset_item:cnn}
+% \begin{syntax}
+% \cs{seq_set_item:Nnn} \meta{seq~var} \Arg{int expr} \Arg{item}
+% \cs{seq_set_item:NnnTF} \meta{seq~var} \Arg{int expr} \Arg{item} \Arg{true code} \Arg{false code}
+% \end{syntax}
+% Removes the item of \meta{sequence} at the position given by
+% evaluating the \meta{int expr} and replaces it by
+% \meta{item}. Items are indexed from $1$ on the left/top of the
+% \meta{sequence}, or from $-1$ on the right/bottom. If the
+% \meta{int expr} is zero or is larger (in absolute value)
+% than the number of items in the sequence, the \meta{sequence} is not
+% modified. In these cases, \cs{seq_set_item:Nnn} raises an error
+% while \cs{seq_set_item:NnnTF} runs the \meta{false code}. In cases
+% where the assignment was successful, \meta{true code} is run
+% afterwards.
+% \end{function}
+%
% \begin{function}[added = 2014-07-18]
% {
% \seq_reverse:N, \seq_reverse:c,
@@ -1513,6 +1531,113 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\@@_int_eval:w}
+% Useful to more quickly go through items.
+% \begin{macrocode}
+\cs_new_eq:NN \@@_int_eval:w \tex_numexpr:D
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[noTF]{\seq_set_item:Nnn, \seq_set_item:cnn, \seq_gset_item:Nnn, \seq_gset_item:cnn}
+% \begin{macro}{\@@_set_item:NnnNN, \@@_set_item:nnNNNN, \@@_set_item_false:nnNNNN, \@@_set_item:nNnnNNNN}
+% \begin{macro}[rEXP]{\@@_set_item:wn, \@@_set_item_end:w}
+% The conditionals are distinguished from the |Nnn| versions by the
+% last argument \cs{use_ii:nn} vs \cs{use_i:nn}.
+% \begin{macrocode}
+\cs_new_protected:Npn \seq_set_item:Nnn #1#2#3
+ { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_set:Nx \use_i:nn }
+\cs_new_protected:Npn \seq_gset_item:Nnn #1#2#3
+ { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_gset:Nx \use_i:nn }
+\cs_generate_variant:Nn \seq_set_item:Nnn { c }
+\cs_generate_variant:Nn \seq_gset_item:Nnn { c }
+\prg_new_protected_conditional:Npnn \seq_set_item:Nnn #1#2#3 { TF , T , F }
+ { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_set:Nx \use_ii:nn }
+\prg_new_protected_conditional:Npnn \seq_gset_item:Nnn #1#2#3 { TF , T , F }
+ { \@@_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_gset:Nx \use_ii:nn }
+\prg_generate_conditional_variant:Nnn \seq_set_item:Nnn { c } { TF , T , F }
+\prg_generate_conditional_variant:Nnn \seq_gset_item:Nnn { c } { TF , T , F }
+% \end{macrocode}
+% Save the item to be stored and evaluate the position and the sequence
+% length only once. Then depending on the sign of the position, check
+% that it is not bigger than the length (in absolute value) nor zero.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_item:NnnNN #1#2#3
+ {
+ \tl_set:Nn \l_@@_internal_a_tl { \@@_item:n {#3} }
+ \exp_args:Nff \@@_set_item:nnNNNN
+ { \int_eval:n {#2} } { \seq_count:N #1 } #1 \use_none:nn
+ }
+\cs_new_protected:Npn \@@_set_item:nnNNNN #1#2
+ {
+ \int_compare:nNnTF {#1} > 0
+ { \int_compare:nNnF {#1} > {#2} { \@@_set_item:nNnnNNNN { #1 - 1 } } }
+ {
+ \int_compare:nNnF {#1} < {-#2}
+ {
+ \int_compare:nNnF {#1} = 0
+ { \@@_set_item:nNnnNNNN { #2 + #1 } }
+ }
+ }
+ \@@_set_item_false:nnNNNN {#1} {#2}
+ }
+% \end{macrocode}
+% If the position is not ok, \cs{@@_set_item_false:nnNNNN} calls an
+% error or returns \texttt{false} (depending on the \cs{use_i:nn} vs
+% \cs{use_ii:nn} argument mentioned above).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_item_false:nnNNNN #1#2#3#4#5#6
+ {
+ #6
+ {
+ \msg_error:nnxxx { seq } { item-too-large }
+ { \token_to_str:N #3 } {#2} {#1}
+ }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% If the position is ok, \cs{@@_set_item:nNnnNNNN} makes the assignment
+% and returns \texttt{true} (in the case of conditionnals). Here |#1|
+% is an integer expression (position minus one), it needs to be
+% evaluated. The sequence |#5| starts with \cs{s_@@} (even if empty),
+% which stops the integer expression and is absorbed by it. The
+% \cs{if_meaning:w} test is slightly faster than an integer test (but
+% only works when testing against zero, hence the offset we chose in
+% the position). When we are done skipping items, insert the saved
+% item \cs{l_@@_internal_a_tl}. For |put| functions the last argument
+% of \cs{@@_set_item_end:w} is \cs{use_none:nn} and it absorbs the
+% item |#2| that we are removing: this is only useful for the |pop|
+% functions.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_item:nNnnNNNN #1#2#3#4#5#6#7#8
+ {
+ #7 #5
+ {
+ \s_@@
+ \exp_after:wN \@@_set_item:wn
+ \int_value:w \@@_int_eval:w #1
+ #5 \s_@@_stop #6
+ }
+ #8 { } { \prg_return_true: }
+ }
+\cs_new:Npn \@@_set_item:wn #1 \@@_item:n #2
+ {
+ \if_meaning:w 0 #1 \@@_set_item_end:w \fi:
+ \exp_not:n { \@@_item:n {#2} }
+ \exp_after:wN \@@_set_item:wn
+ \int_value:w \@@_int_eval:w #1 - 1 \s_@@
+ }
+\cs_new:Npn \@@_set_item_end:w #1 \exp_not:n #2 #3 \s_@@ #4 \s_@@_stop #5
+ {
+ #1
+ \exp_not:o \l_@@_internal_a_tl
+ \exp_not:n {#4}
+ #5 #2
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}
% {\seq_reverse:N, \seq_reverse:c, \seq_greverse:N, \seq_greverse:c}
% \begin{macro}{\@@_reverse:NN}
More information about the latex3-commits
mailing list.