[latex3-commits] [l3svn] r6793 - Change some __sort to @@
noreply at latex-project.org
noreply at latex-project.org
Thu Dec 15 06:28:37 CET 2016
Author: bruno
Date: 2016-12-15 06:28:36 +0100 (Thu, 15 Dec 2016)
New Revision: 6793
Modified:
trunk/l3experimental/l3sort/l3sort.dtx
Log:
Change some __sort to @@
Modified: trunk/l3experimental/l3sort/l3sort.dtx
===================================================================
--- trunk/l3experimental/l3sort/l3sort.dtx 2016-12-15 05:25:52 UTC (rev 6792)
+++ trunk/l3experimental/l3sort/l3sort.dtx 2016-12-15 05:28:36 UTC (rev 6793)
@@ -82,6 +82,7 @@
% \maketitle
%
% \begin{documentation}
+% ^^A todo: ask list about ltplain, mkpattern.tex, GFnotation.tex, texinfo.tex, lollipop-plain, etex-mac.tex,
%
% \section{\pkg{l3sort} documentation}
%
@@ -721,8 +722,8 @@
%
% A prototypical version of expandable quicksort is as follows. If the
% argument has no item, return nothing, otherwise partition, using the
-% first item as a pivot (argument |#4| of |\__sort:nnNnn|). The
-% arguments of |\__sort:nnNnn| are 1.~items less than |#4|, 2.~items
+% first item as a pivot (argument |#4| of \cs{@@:nnNnn}). The
+% arguments of \cs{@@:nnNnn} are 1.~items less than |#4|, 2.~items
% greater or equal to |#4|, 3.~comparison, 4.~pivot, 5.~next item to
% test. If |#5| is the tail of the list, call \cs{tl_sort:nN} on |#1|
% and on |#2|, placing |#4| in between; |\use:ff| expands the parts to
@@ -752,41 +753,41 @@
% There are quite a few optimizations available here: the code below is
% less legible, but more than twice as fast.
%
-% In the simple version of the code, |\__sort:nnNnn| is called
+% In the simple version of the code, \cs{@@:nnNnn} is called
% \(O(n\ln n)\) times on average (the number of comparisons required by
% the quicksort algorithm). Hence most of our focus will be on
% optimizing that function.
%
% The first speed up is to avoid testing for the end of the list at
-% every call to |\__sort:nnNnn|. For this, the list is prepared by
+% every call to \cs{@@:nnNnn}. For this, the list is prepared by
% changing each \meta{item} of the original token list into
% \meta{command} \Arg{item}, just like sequences are stored. We arrange
% things such that the \meta{command} is the \meta{conditional} provided
% by the user: the loop over the \meta{prepared tokens} then looks like
% \begin{quote}
% \ttfamily
-% \cs{cs_new:Npn}~|\__sort_loop:wNn|~\ldots{}~|#6#7|\\
+% \cs{cs_new:Npn}~\cs{@@_loop:wNn}~\ldots{}~|#6#7|\\
% ~~|{|\\
% ~~~~|#6|~\Arg{pivot}~|{#7}|~\meta{loop big}~\meta{loop small}\\
% ~~~~~~\meta{extra arguments}\\
% ~~|}|\\
-% |\__sort_loop:wNn|~\ldots{}~\meta{prepared tokens}\\
+% \cs{@@_loop:wNn}~\ldots{}~\meta{prepared tokens}\\
% ~~\meta{end-loop}~|{}|~|\q_stop|
% \end{quote}
% In this example, which matches the structure of
-% \cs{__sort_quick_split_i:NnnnnNn} and a few other functions below, the
-% |\__sort_loop:wNn| auxiliary normally receives the user's
+% \cs{@@_quick_split_i:NnnnnNn} and a few other functions below, the
+% \cs{@@_loop:wNn} auxiliary normally receives the user's
% \meta{conditional} as~|#6| and an \meta{item} as~|#7|. This is
% compared to the \meta{pivot} (the argument~|#5|, not shown here), and
% the \meta{conditional} leaves the \meta{loop big} or \meta{loop small}
-% auxiliary, which both have the same form as |\__sort_loop:wNn|,
+% auxiliary, which both have the same form as \cs{@@_loop:wNn},
% receiving the next pair \meta{conditional} \Arg{item} as |#6|
% and~|#7|. At the end, |#6| is the \meta{end-loop} function, which
% terminates the loop.
%
% The second speed up is to minimize the duplicated tokens between the
% \texttt{true} and \texttt{false} branches of the conditional. For
-% this, we introduce two versions of |\__sort:nnNnn|, which receive
+% this, we introduce two versions of \cs{@@:nnNnn}, which receive
% the new item as~|#1| and place it either into the list~|#2| of items
% less than the pivot~|#4| or into the list~|#3| of items greater or
% equal to the pivot.
@@ -802,7 +803,7 @@
% {#6} {#2} { #3 {#1} } {#4}
% }
% \end{verbatim}
-% Note that the two functions have the form of |\__sort_loop:wNn| above,
+% Note that the two functions have the form of \cs{@@_loop:wNn} above,
% receiving as~|#5| the conditional or a function to end the loop. In
% fact, the lists~|#2| and~|#3| must be made of pairs \meta{conditional}
% \Arg{item}, so we have to replace~|{#6}| above by |{|~|#5|~|{#6}|~|}|,
@@ -810,14 +811,14 @@
% all argument numbers are shifted compared to this code.
%
% The third speed up is to avoid |\use:ff| using a continuation-passing
-% style: \cs{__sort_quick_split:NnNn} expects a list followed by
+% style: \cs{@@_quick_split:NnNn} expects a list followed by
% \cs{q_mark} \Arg{code}, and expands to \meta{code} \meta{sorted list}.
% Sorting the two parts of the list around the pivot is done with
% \begin{quote}
% \ttfamily
-% \cs{__sort_quick_split:NnNn} |#2| \ldots{} \cs{q_mark}\\
+% \cs{@@_quick_split:NnNn} |#2| \ldots{} \cs{q_mark}\\
% ~~|{|\\
-% ~~~~\cs{__sort_quick_split:NnNn} |#1| \ldots{} \cs{q_mark} \Arg{code}\\
+% ~~~~\cs{@@_quick_split:NnNn} |#1| \ldots{} \cs{q_mark} \Arg{code}\\
% ~~~~\Arg{pivot}\\
% ~~|}|
% \end{quote}
@@ -827,10 +828,10 @@
%
% The fourth speed up is avoid the recursive call to \cs{tl_sort:nN}
% with an empty first argument. For this, we introduce functions
-% similar to the |\__sort_i:nnnnNn| of the last example, but aware of
+% similar to the \cs{@@_i:nnnnNn} of the last example, but aware of
% whether the list of \meta{conditional} \Arg{item} read so far that are
% less than the pivot, and the list of those greater or equal, are empty
-% or not: see \cs{__sort_quick_split:NnNn} and functions defined below.
+% or not: see \cs{@@_quick_split:NnNn} and functions defined below.
% Knowing whether the lists are empty or not is useless if we do not use
% distinct ending codes as appropriate. The splitting auxiliaries
% communicate to the \meta{end-loop} function (that is initially placed
@@ -859,9 +860,9 @@
% \begin{macro}[EXP]{\tl_sort:nN}
% \begin{macro}[aux, EXP]
% {
-% \__sort_quick_prepare:Nnnn,
-% \__sort_quick_prepare_end:NNNnw,
-% \__sort_quick_cleanup:w
+% \@@_quick_prepare:Nnnn,
+% \@@_quick_prepare_end:NNNnw,
+% \@@_quick_cleanup:w
% }
% The code within the \cs{exp_not:f} sorts the list, leaving in most
% cases a leading \cs{exp_not:f}, which stops the expansion, letting
@@ -873,7 +874,7 @@
% item as~|#3|, and the item after that as~|#4|. The loop ends
% when~|#4| contains \cs{__prg_break_point:}, then the
% \texttt{prepare_end} auxiliary finds the prepared token list
-% as~|#4|. The scene is then set up for \cs{__sort_quick_split:NnNn},
+% as~|#4|. The scene is then set up for \cs{@@_quick_split:NnNn},
% which will sort the prepared list and perform the post action placed
% after \cs{q_mark}, namely removing the trailing \cs{s__stop} and
% \cs{q_stop} and leaving \cs{exp_stop_f:} to stop
@@ -885,36 +886,36 @@
{
\tl_if_blank:nF {#1}
{
- \__sort_quick_prepare:Nnnn #2 { } { }
+ \@@_quick_prepare:Nnnn #2 { } { }
#1
- { \__prg_break_point: \__sort_quick_prepare_end:NNNnw }
+ { \__prg_break_point: \@@_quick_prepare_end:NNNnw }
\q_stop
}
}
}
-\cs_new:Npn \__sort_quick_prepare:Nnnn #1#2#3#4
+\cs_new:Npn \@@_quick_prepare:Nnnn #1#2#3#4
{
\__prg_break: #4 \__prg_break_point:
- \__sort_quick_prepare:Nnnn #1 { #2 #3 } { #1 {#4} }
+ \@@_quick_prepare:Nnnn #1 { #2 #3 } { #1 {#4} }
}
-\cs_new:Npn \__sort_quick_prepare_end:NNNnw #1#2#3#4#5 \q_stop
+\cs_new:Npn \@@_quick_prepare_end:NNNnw #1#2#3#4#5 \q_stop
{
- \__sort_quick_split:NnNn #4 \__sort_quick_end:nnTFNn { }
- \q_mark { \__sort_quick_cleanup:w \exp_stop_f: }
+ \@@_quick_split:NnNn #4 \@@_quick_end:nnTFNn { }
+ \q_mark { \@@_quick_cleanup:w \exp_stop_f: }
\s__stop \q_stop
}
-\cs_new:Npn \__sort_quick_cleanup:w #1 \s__stop \q_stop {#1}
+\cs_new:Npn \@@_quick_cleanup:w #1 \s__stop \q_stop {#1}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}[EXP, aux]
% {
-% \__sort_quick_split:NnNn,
-% \__sort_quick_only_i:NnnnnNn,
-% \__sort_quick_only_ii:NnnnnNn,
-% \__sort_quick_split_i:NnnnnNn,
-% \__sort_quick_split_ii:NnnnnNn
+% \@@_quick_split:NnNn,
+% \@@_quick_only_i:NnnnnNn,
+% \@@_quick_only_ii:NnnnnNn,
+% \@@_quick_split_i:NnnnnNn,
+% \@@_quick_split_ii:NnnnnNn
% }
% The \texttt{only_i}, \texttt{only_ii}, \texttt{split_i} and
% \texttt{split_ii} auxiliaries receive a useless first argument, the
@@ -923,7 +924,7 @@
% items~|#4|, the pivot~|#5|, a \meta{function}~|#6|, and an
% item~|#7|. The \meta{function} is the user's \meta{conditional}
% except at the end of the list where it is
-% \cs{__sort_quick_end:nnTFNn}. The comparison is applied to the
+% \cs{@@_quick_end:nnTFNn}. The comparison is applied to the
% \meta{pivot} and the \meta{item}, and calls the \texttt{only_i} or
% \texttt{split_i} auxiliaries if the \meta{item} is smaller, and the
% \texttt{only_ii} or \texttt{split_ii} auxiliaries otherwise. In
@@ -937,34 +938,34 @@
% argument is always the user's \meta{conditional} rather than an
% ending function.
% \begin{macrocode}
-\cs_new:Npn \__sort_quick_split:NnNn #1#2#3#4
+\cs_new:Npn \@@_quick_split:NnNn #1#2#3#4
{
- #3 {#2} {#4} \__sort_quick_only_ii:NnnnnNn \__sort_quick_only_i:NnnnnNn
- \__sort_quick_single_end:nnnwnw
+ #3 {#2} {#4} \@@_quick_only_ii:NnnnnNn \@@_quick_only_i:NnnnnNn
+ \@@_quick_single_end:nnnwnw
{ #3 {#4} } { } { } {#2}
}
-\cs_new:Npn \__sort_quick_only_i:NnnnnNn #1#2#3#4#5#6#7
+\cs_new:Npn \@@_quick_only_i:NnnnnNn #1#2#3#4#5#6#7
{
- #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_only_i:NnnnnNn
- \__sort_quick_only_i_end:nnnwnw
+ #6 {#5} {#7} \@@_quick_split_ii:NnnnnNn \@@_quick_only_i:NnnnnNn
+ \@@_quick_only_i_end:nnnwnw
{ #6 {#7} } { #3 #2 } { } {#5}
}
-\cs_new:Npn \__sort_quick_only_ii:NnnnnNn #1#2#3#4#5#6#7
+\cs_new:Npn \@@_quick_only_ii:NnnnnNn #1#2#3#4#5#6#7
{
- #6 {#5} {#7} \__sort_quick_only_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn
- \__sort_quick_only_ii_end:nnnwnw
+ #6 {#5} {#7} \@@_quick_only_ii:NnnnnNn \@@_quick_split_i:NnnnnNn
+ \@@_quick_only_ii_end:nnnwnw
{ #6 {#7} } { } { #4 #2 } {#5}
}
-\cs_new:Npn \__sort_quick_split_i:NnnnnNn #1#2#3#4#5#6#7
+\cs_new:Npn \@@_quick_split_i:NnnnnNn #1#2#3#4#5#6#7
{
- #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn
- \__sort_quick_split_end:nnnwnw
+ #6 {#5} {#7} \@@_quick_split_ii:NnnnnNn \@@_quick_split_i:NnnnnNn
+ \@@_quick_split_end:nnnwnw
{ #6 {#7} } { #3 #2 } {#4} {#5}
}
-\cs_new:Npn \__sort_quick_split_ii:NnnnnNn #1#2#3#4#5#6#7
+\cs_new:Npn \@@_quick_split_ii:NnnnnNn #1#2#3#4#5#6#7
{
- #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn
- \__sort_quick_split_end:nnnwnw
+ #6 {#5} {#7} \@@_quick_split_ii:NnnnnNn \@@_quick_split_i:NnnnnNn
+ \@@_quick_split_end:nnnwnw
{ #6 {#7} } {#3} { #4 #2 } {#5}
}
% \end{macrocode}
@@ -972,13 +973,13 @@
%
% \begin{macro}[EXP, aux]
% {
-% \__sort_quick_end:nnTFNn,
-% \__sort_quick_single_end:nnnwnw,
-% \__sort_quick_only_i_end:nnnwnw,
-% \__sort_quick_only_ii_end:nnnwnw,
-% \__sort_quick_split_end:nnnwnw,
+% \@@_quick_end:nnTFNn,
+% \@@_quick_single_end:nnnwnw,
+% \@@_quick_only_i_end:nnnwnw,
+% \@@_quick_only_ii_end:nnnwnw,
+% \@@_quick_split_end:nnnwnw,
% }
-% The \cs{__sort_quick_end:nnTFNn} appears instead of the user's
+% The \cs{@@_quick_end:nnTFNn} appears instead of the user's
% conditional, and receives as its arguments the pivot~|#1|, a fake
% item~|#2|, a \texttt{true} and a \texttt{false} branches |#3|
% and~|#4|, followed by an ending function~|#5| (one of the four
@@ -999,28 +1000,28 @@
% the pivot are sorted, then items less than the pivot, and the
% continuations are done in such a way to place the pivot in between.
% \begin{macrocode}
-\cs_new:Npn \__sort_quick_end:nnTFNn #1#2#3#4#5#6 {#5}
-\cs_new:Npn \__sort_quick_single_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
+\cs_new:Npn \@@_quick_end:nnTFNn #1#2#3#4#5#6 {#5}
+\cs_new:Npn \@@_quick_single_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
{ #5 {#3} #6 \q_stop }
-\cs_new:Npn \__sort_quick_only_i_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
+\cs_new:Npn \@@_quick_only_i_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
{
- \__sort_quick_split:NnNn #1
- \__sort_quick_end:nnTFNn { } \q_mark {#5}
+ \@@_quick_split:NnNn #1
+ \@@_quick_end:nnTFNn { } \q_mark {#5}
{#3}
#6 \q_stop
}
-\cs_new:Npn \__sort_quick_only_ii_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
+\cs_new:Npn \@@_quick_only_ii_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
{
- \__sort_quick_split:NnNn #2
- \__sort_quick_end:nnTFNn { } \q_mark { #5 {#3} }
+ \@@_quick_split:NnNn #2
+ \@@_quick_end:nnTFNn { } \q_mark { #5 {#3} }
#6 \q_stop
}
-\cs_new:Npn \__sort_quick_split_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
+\cs_new:Npn \@@_quick_split_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop
{
- \__sort_quick_split:NnNn #2 \__sort_quick_end:nnTFNn { } \q_mark
+ \@@_quick_split:NnNn #2 \@@_quick_end:nnTFNn { } \q_mark
{
- \__sort_quick_split:NnNn #1
- \__sort_quick_end:nnTFNn { } \q_mark {#5}
+ \@@_quick_split:NnNn #1
+ \@@_quick_end:nnTFNn { } \q_mark {#5}
{#3}
}
#6 \q_stop
More information about the latex3-commits
mailing list