[latex3-commits] [git/LaTeX3-latex3-latex3] master: Move RNG seed functions to stable (1862610f8)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Sep 20 12:48:06 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/1862610f81fd04d56be3b701bb4a38b7d93e2ed3

>---------------------------------------------------------------

commit 1862610f81fd04d56be3b701bb4a38b7d93e2ed3
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Sep 20 11:48:06 2019 +0100

    Move RNG seed functions to stable
    
    The test for a RNG can stay experimental:
    once we require TL'19 XeTeX, it will go.


>---------------------------------------------------------------

1862610f81fd04d56be3b701bb4a38b7d93e2ed3
 l3kernel/CHANGELOG.md                   |  2 +
 l3kernel/l3candidates.dtx               | 64 -------------------------------
 l3kernel/l3sys.dtx                      | 68 +++++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3expl001.luatex.tlg |  4 +-
 l3kernel/testfiles/m3expl001.ptex.tlg   |  4 +-
 l3kernel/testfiles/m3expl001.tlg        |  4 +-
 l3kernel/testfiles/m3expl001.uptex.tlg  |  4 +-
 l3kernel/testfiles/m3expl001.xetex.tlg  |  4 +-
 l3kernel/testfiles/m3expl003.luatex.tlg |  4 +-
 l3kernel/testfiles/m3expl003.ptex.tlg   |  4 +-
 l3kernel/testfiles/m3expl003.tlg        |  4 +-
 l3kernel/testfiles/m3expl003.uptex.tlg  |  4 +-
 l3kernel/testfiles/m3expl003.xetex.tlg  |  4 +-
 13 files changed, 90 insertions(+), 84 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index ca8c170e8..2c85476b0 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -25,6 +25,8 @@ this project uses date-based 'snapshot' version identifiers.
   - `\seq_(g)shuffle:N`
   - `\sys_if_platform_unix:(TF)`
   - `\sys_if_platform_windows:(TF)`
+  - `\sys_gset_rand_seed:`
+  - `\sys_rand_seed:`
 
 ## [2019-09-19]
 
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 27232f37f..a0f6f725a 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -675,33 +675,6 @@
 %   this is the case in \pdfTeX{}, \LuaTeX{}, \pTeX{} and \upTeX{}.
 % \end{function}
 %
-% \begin{function}[added = 2017-05-27, EXP]{\sys_rand_seed:}
-%   \begin{syntax}
-%     \cs{sys_rand_seed:}
-%   \end{syntax}
-%   Expands to the current value of the engine's random seed, a
-%   non-negative integer.  In engines without random number support this
-%   expands to $0$.
-% \end{function}
-%
-% \begin{function}[added = 2017-05-27]{\sys_gset_rand_seed:n}
-%   \begin{syntax}
-%     \cs{sys_gset_rand_seed:n} \Arg{intexpr}
-%   \end{syntax}
-%   Globally sets the seed for the engine's pseudo-random number
-%   generator to the \meta{integer expression}.  This random seed
-%   affects all \cs[no-index]{\ldots{}_rand} functions (such as
-%   \cs{int_rand:nn} or \cs{clist_rand_item:n}) as well as other
-%   packages relying on the engine's random number generator.  In
-%   engines without random number support this produces an error.
-%   \begin{texnote}
-%     While a $32$-bit (signed) integer can be given as a seed, only the
-%     absolute value is used and any number beyond $2^{28}$ is divided
-%     by an appropriate power of~$2$.  We recommend using an integer in
-%     $[0,2^{28}-1]$.
-%   \end{texnote}
-% \end{function}
-%
 % \begin{variable}[added = 2017-05-27]{\c_sys_shell_escape_int}
 %   This variable exposes the internal triple of the shell escape
 %   status.  The possible values are
@@ -1755,43 +1728,6 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}[EXP]{\sys_rand_seed:}
-%   Unpack the primitive.  When random numbers are not available, we
-%   return zero after an error (and incidentally make sure the number of
-%   expansions needed is the same as with random numbers available).
-%    \begin{macrocode}
-\sys_if_rand_exist:TF
-  { \cs_new:Npn \sys_rand_seed: { \tex_the:D \tex_randomseed:D } }
-  {
-    \cs_new:Npn \sys_rand_seed:
-      {
-        \int_value:w
-        \__kernel_msg_expandable_error:nnn { kernel } { fp-no-random }
-          { \sys_rand_seed: }
-        \c_zero_int
-      }
-  }
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\sys_gset_rand_seed:n}
-%   The primitive always assigns the seed globally.
-%    \begin{macrocode}
-\sys_if_rand_exist:TF
-  {
-    \cs_new_protected:Npn \sys_gset_rand_seed:n #1
-      { \tex_setrandomseed:D \int_eval:n {#1} \exp_stop_f: }
-  }
-  {
-    \cs_new_protected:Npn \sys_gset_rand_seed:n #1
-      {
-        \__kernel_msg_error:nnn { kernel } { fp-no-random }
-          { \sys_gset_rand_seed:n {#1} }
-      }
-  }
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{variable}{\c_sys_shell_escape_int}
 %   Expose the engine's shell escape status to the user.
 %    \begin{macrocode}
diff --git a/l3kernel/l3sys.dtx b/l3kernel/l3sys.dtx
index 45c1e430b..11217081b 100644
--- a/l3kernel/l3sys.dtx
+++ b/l3kernel/l3sys.dtx
@@ -146,6 +146,35 @@
 %   |unix|, |windows| or |unknown|.
 % \end{variable}
 %
+% \section{Random numbers}
+%
+% \begin{function}[added = 2017-05-27, EXP]{\sys_rand_seed:}
+%   \begin{syntax}
+%     \cs{sys_rand_seed:}
+%   \end{syntax}
+%   Expands to the current value of the engine's random seed, a
+%   non-negative integer.  In engines without random number support this
+%   expands to $0$.
+% \end{function}
+%
+% \begin{function}[added = 2017-05-27]{\sys_gset_rand_seed:n}
+%   \begin{syntax}
+%     \cs{sys_gset_rand_seed:n} \Arg{intexpr}
+%   \end{syntax}
+%   Globally sets the seed for the engine's pseudo-random number
+%   generator to the \meta{integer expression}.  This random seed
+%   affects all \cs[no-index]{\ldots{}_rand} functions (such as
+%   \cs{int_rand:nn} or \cs{clist_rand_item:n}) as well as other
+%   packages relying on the engine's random number generator.  In
+%   engines without random number support this produces an error.
+%   \begin{texnote}
+%     While a $32$-bit (signed) integer can be given as a seed, only the
+%     absolute value is used and any number beyond $2^{28}$ is divided
+%     by an appropriate power of~$2$.  We recommend using an integer in
+%     $[0,2^{28}-1]$.
+%   \end{texnote}
+% \end{function}
+%
 % \end{documentation}
 %
 % \begin{implementation}
@@ -347,6 +376,45 @@
 % \end{variable}
 % \end{macro}
 %
+% \subsection{Random numbers}
+%
+% \begin{macro}[EXP]{\sys_rand_seed:}
+%   Unpack the primitive.  When random numbers are not available, we
+%   return zero after an error (and incidentally make sure the number of
+%   expansions needed is the same as with random numbers available).
+%    \begin{macrocode}
+\sys_if_rand_exist:TF
+  { \cs_new:Npn \sys_rand_seed: { \tex_the:D \tex_randomseed:D } }
+  {
+    \cs_new:Npn \sys_rand_seed:
+      {
+        \int_value:w
+        \__kernel_msg_expandable_error:nnn { kernel } { fp-no-random }
+          { \sys_rand_seed: }
+        \c_zero_int
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sys_gset_rand_seed:n}
+%   The primitive always assigns the seed globally.
+%    \begin{macrocode}
+\sys_if_rand_exist:TF
+  {
+    \cs_new_protected:Npn \sys_gset_rand_seed:n #1
+      { \tex_setrandomseed:D \int_eval:n {#1} \exp_stop_f: }
+  }
+  {
+    \cs_new_protected:Npn \sys_gset_rand_seed:n #1
+      {
+        \__kernel_msg_error:nnn { kernel } { fp-no-random }
+          { \sys_gset_rand_seed:n {#1} }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 4d6469714..700fbe29d 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -1764,6 +1764,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6494,8 +6496,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index fba4d4222..ffd3ebfa0 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6489,8 +6491,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 25685f6ad..782b56374 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6489,8 +6491,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index c0172ab74..eee9b57c6 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6485,8 +6487,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 5bd1c5654..467ba7a50 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6493,8 +6495,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 4d6469714..700fbe29d 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -1764,6 +1764,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6494,8 +6496,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index fba4d4222..ffd3ebfa0 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6489,8 +6491,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 25685f6ad..782b56374 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6489,8 +6491,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index c0172ab74..eee9b57c6 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6485,8 +6487,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 5bd1c5654..467ba7a50 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -1762,6 +1762,8 @@ Defining \sys_if_rand_exist:T on line ...
 Defining \sys_if_rand_exist:F on line ...
 Defining \sys_if_rand_exist:TF on line ...
 Defining \sys_if_rand_exist_p: on line ...
+Defining \sys_rand_seed: on line ...
+Defining \sys_gset_rand_seed:n on line ...
 Defining \c_empty_clist on line ...
 Defining \l__clist_internal_clist on line ...
 Defining \__clist_tmp:w on line ...
@@ -6493,8 +6495,6 @@ Defining \seq_indexed_map_inline:Nn on line ...
 Defining \__seq_indexed_map:NN on line ...
 Defining \__seq_indexed_map:Nw on line ...
 Defining \c_sys_engine_version_str on line ...
-Defining \sys_rand_seed: on line ...
-Defining \sys_gset_rand_seed:n on line ...
 Defining \c_sys_shell_escape_int on line ...
 Defining \l__sys_internal_tl on line ...
 Defining \c__sys_marker_tl on line ...





More information about the latex3-commits mailing list