[latex3-commits] [latex3/latex3] main: Explain why `\str_const:Nn` uses `\cs_gset_nopar:Npe` (1fe9bd815)

github at latex-project.org github at latex-project.org
Sun Nov 26 21:51:43 CET 2023


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/1fe9bd81572e190b29aa5bf78e927962daac086c

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

commit 1fe9bd81572e190b29aa5bf78e927962daac086c
Author: Yukai Chou <muzimuzhi at gmail.com>
Date:   Sun Nov 26 04:59:32 2023 +0800

    Explain why `\str_const:Nn` uses `\cs_gset_nopar:Npe`
    
    And considerations for preventing further expansion in
    `\str_(g)put_left:Nn` and `\str_(g)put_right:Nn`.


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

1fe9bd81572e190b29aa5bf78e927962daac086c
 l3kernel/l3str.dtx | 8 ++++++++
 l3kernel/l3tl.dtx  | 7 +++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/l3kernel/l3str.dtx b/l3kernel/l3str.dtx
index 5787fbfbd..9d838ec71 100644
--- a/l3kernel/l3str.dtx
+++ b/l3kernel/l3str.dtx
@@ -981,6 +981,14 @@
 %   }
 %   Similar to corresponding \pkg{l3tl} base functions, except that
 %   \cs{__kernel_exp_not:w} is replaced with \cs{__kernel_tl_to_str:w}.
+%   Just like token list, string constants use \cs{cs_gset_nopar:Npe}
+%   instead of \cs{__kernel_tl_gset:Ne} so that the scope checking for
+%   |c| is applied when \pkg{l3debug} is used.
+%   To maintain backward compatibility, in
+%     \cs[index=str_put_left:Nn]{str_(g)put_left:Nn} and
+%     \cs[index=str_put_right:Nn]{str_(g)put_right:Nn},
+%   contents of string variables are wrapped in \cs{__kernel_exp_not:w}
+%   to prevent further expansion.
 %    \begin{macrocode}
 \cs_new_protected:Npn \str_set:Nn #1#2
   { \__kernel_tl_set:Ne #1 { \__kernel_tl_to_str:w {#2} } }
diff --git a/l3kernel/l3tl.dtx b/l3kernel/l3tl.dtx
index cf506b9fe..1b6b9367d 100644
--- a/l3kernel/l3tl.dtx
+++ b/l3kernel/l3tl.dtx
@@ -1352,8 +1352,11 @@
 %     \tl_const:cn, \tl_const:ce, \tl_const:cx
 %   }
 %   Constants are also easy to generate. They use \cs{cs_gset_nopar:Npe} instead
-%   of \cs{__kernel_tl_gset:Ne} so that the correct scope checking is applied if
-%   \pkg{l3debug} is used.
+%   of \cs{__kernel_tl_gset:Ne} so that the correct scope checking for |c|,
+%   instead of for |g|, is applied when
+%   \cs{debug_on:n} |{ check-declarations }| is used.
+%   Constant assignment functions are patched specially in \pkg{l3debug} to
+%   apply such checks.
 %    \begin{macrocode}
 \cs_new_protected:Npn \tl_const:Nn #1#2
   {





More information about the latex3-commits mailing list.