[latex3-commits] [git/LaTeX3-latex3-latex3] main: Drop "code" key type for templates (1adf26e45)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Jan 12 22:02:01 CET 2023


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

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

commit 1adf26e459fe9b40c31d23293f2e5a4b9d527639
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Jan 12 21:01:46 2023 +0000

    Drop "code" key type for templates


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

1adf26e459fe9b40c31d23293f2e5a4b9d527639
 l3packages/CHANGELOG.md                         |  3 ++
 l3packages/xtemplate/testfiles/xtemplate001.lvt |  6 ++--
 l3packages/xtemplate/testfiles/xtemplate001.tlg | 12 +++----
 l3packages/xtemplate/testfiles/xtemplate002.lvt | 21 -----------
 l3packages/xtemplate/testfiles/xtemplate002.tlg |  7 +---
 l3packages/xtemplate/testfiles/xtemplate003.lvt |  2 --
 l3packages/xtemplate/testfiles/xtemplate003.tlg | 14 ++++----
 l3packages/xtemplate/xtemplate.dtx              | 47 ++++---------------------
 8 files changed, 22 insertions(+), 90 deletions(-)

diff --git a/l3packages/CHANGELOG.md b/l3packages/CHANGELOG.md
index eec88280b..5d7a7a63f 100644
--- a/l3packages/CHANGELOG.md
+++ b/l3packages/CHANGELOG.md
@@ -10,6 +10,9 @@ this project uses date-based 'snapshot' version identifiers.
 ### Fixed
 - Ad hoc adjustment of template `function` keys
 
+### Removed
+- Template key type `code`
+
 ## [2022-12-17]
 
 ### Fixed
diff --git a/l3packages/xtemplate/testfiles/xtemplate001.lvt b/l3packages/xtemplate/testfiles/xtemplate001.lvt
index 8c62aa05e..773b92bf6 100644
--- a/l3packages/xtemplate/testfiles/xtemplate001.lvt
+++ b/l3packages/xtemplate/testfiles/xtemplate001.lvt
@@ -33,8 +33,7 @@
     key-one   : tokenlist = default ,
     key-two   : tokenlist           ,
     key-three : integer   = 4       ,
-    key-four  : choice { one, two, three },
-    key-five  : code      = {#1}
+    key-four  : choice { one, two, three }
   }
   \ShowTemplateKeytypes { test-zero }  { template }
   \ShowTemplateDefaults { test-zero }  { template }
@@ -53,8 +52,7 @@
     key-one   : tokenlist = default ,
     key-two   : tokenlist           ,
     key-three : integer   = 4       ,
-    key-four  : choice { one, two, three },
-    key-five  : code      = {#1}
+    key-four  : choice { one, two, three }
   }
   \ShowTemplateKeytypes{test-three}{template}
   \ShowTemplateDefaults{test-three}{template}
diff --git a/l3packages/xtemplate/testfiles/xtemplate001.tlg b/l3packages/xtemplate/testfiles/xtemplate001.tlg
index 70a8d02e7..bfcba34cd 100644
--- a/l3packages/xtemplate/testfiles/xtemplate001.tlg
+++ b/l3packages/xtemplate/testfiles/xtemplate001.tlg
@@ -21,14 +21,12 @@ The template 'template' of object type 'test-zero' has interface:
 >  key-one  =>  tokenlist
 >  key-two  =>  tokenlist
 >  key-three  =>  integer
->  key-four  =>  choice{one,two,three}
->  key-five  =>  code.
+>  key-four  =>  choice{one,two,three}.
 <recently read> }
 l. ...}
 The template 'template' of object type 'test-zero' has default values:
 >  key-one  =>  default
->  key-three  =>  4
->  key-five  =>  ##1.
+>  key-three  =>  4.
 <recently read> }
 l. ...}
 ============================================================
@@ -72,14 +70,12 @@ The template 'template' of object type 'test-three' has interface:
 >  key-one  =>  tokenlist
 >  key-two  =>  tokenlist
 >  key-three  =>  integer
->  key-four  =>  choice{ one, two, three }
->  key-five  =>  code.
+>  key-four  =>  choice{ one, two, three }.
 <recently read> }
 l. ...}
 The template 'template' of object type 'test-three' has default values:
 >  key-one  =>  default
->  key-three  =>  4
->  key-five  =>  ##1.
+>  key-three  =>  4.
 <recently read> }
 l. ...}
 ============================================================
diff --git a/l3packages/xtemplate/testfiles/xtemplate002.lvt b/l3packages/xtemplate/testfiles/xtemplate002.lvt
index e74637ab0..5708e0ee2 100644
--- a/l3packages/xtemplate/testfiles/xtemplate002.lvt
+++ b/l3packages/xtemplate/testfiles/xtemplate002.lvt
@@ -48,27 +48,6 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\OMIT
-\DeclareTemplateInterface{obj}{tmpt2}{0}
-{
-  akey: code,
-}
-
-\DeclareTemplateCode{obj}{tmpt2}{0}
-{
-  akey = \def\aaa{#1},
-}
-{ \TYPE{(a:~\aaa)} }
-
-\DeclareInstance {obj}{inst3} {tmpt2}{akey=a!}
-\TIMO
-
-\TEST{Testing~CODE~keytype}{
-  \UseInstance{obj}{inst3}
-}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
 \OMIT
 \DeclareTemplateInterface{obj}{tmpt3}{0}
 {
diff --git a/l3packages/xtemplate/testfiles/xtemplate002.tlg b/l3packages/xtemplate/testfiles/xtemplate002.tlg
index 22ff027c8..5d5504b59 100644
--- a/l3packages/xtemplate/testfiles/xtemplate002.tlg
+++ b/l3packages/xtemplate/testfiles/xtemplate002.tlg
@@ -9,12 +9,7 @@ TEST 1: Testing TOKENLIST keytype
 (a: ) (b: ) (c: glob)
 ============================================================
 ============================================================
-TEST 2: Testing CODE keytype
-============================================================
-(a: a!)
-============================================================
-============================================================
-TEST 3: Testing CHOICE keytype
+TEST 2: Testing CHOICE keytype
 ============================================================
 (c: keyx)
 (c: keyy)
diff --git a/l3packages/xtemplate/testfiles/xtemplate003.lvt b/l3packages/xtemplate/testfiles/xtemplate003.lvt
index d188532c7..83609a7fb 100644
--- a/l3packages/xtemplate/testfiles/xtemplate003.lvt
+++ b/l3packages/xtemplate/testfiles/xtemplate003.lvt
@@ -90,7 +90,6 @@
   \DeclareTemplateInterface{ test } {tname} {1}
       { key 1 : boolean  ,
         key 2 : choice {a, b} ,
-        key 3 : code ,
         key 4 : commalist ,
         key 5 : function 3 ,
         key 6 : instance {foo} ,
@@ -185,7 +184,6 @@
   \DeclareTemplateInterface{ test } {tname} {1}
       { key 1 : boolean = false ,
         key 2 : choice {a, b} = b ,
-        key 3 : code ,
         key 4 : commalist = {1,2},
         key 5 : function 3 = (#3#2#1),
         key 6 : instance {foo} = bar,
diff --git a/l3packages/xtemplate/testfiles/xtemplate003.tlg b/l3packages/xtemplate/testfiles/xtemplate003.tlg
index 671e6e783..960daeb55 100644
--- a/l3packages/xtemplate/testfiles/xtemplate003.tlg
+++ b/l3packages/xtemplate/testfiles/xtemplate003.tlg
@@ -58,7 +58,6 @@ l. ...}
 Valid key-types are:
 - boolean;
 - choice;
-- code;
 - commalist;
 - function;
 - instance;
@@ -74,7 +73,6 @@ Defining \template key order > test/tname on line ...
 The template 'tname' of object type 'test' has interface:
 >  key1  =>  boolean
 >  key2  =>  choice{a,b}
->  key3  =>  code
 >  key4  =>  commalist
 >  key5  =>  function{3}
 >  key6  =>  instance{foo}
@@ -96,7 +94,7 @@ but LaTeX could not find a <key-type>.
 TEST 4: Testing key names
 ============================================================
 ! Package xtemplate Error: Key 'key' appears twice in interface definition on
-(xtemplate)                line 126.
+(xtemplate)                line 125.
 For immediate help type H <return>.
  ...                                              
 l. ...}
@@ -118,7 +116,7 @@ This should be given using \DeclareTemplateCode .
 TEST 5: Testing incomplete key types
 ============================================================
 ! Package xtemplate Error: The key type 'choice' requires an argument on line
-(xtemplate)                141.
+(xtemplate)                140.
 For immediate help type H <return>.
  ...                                              
 l. ...}
@@ -126,7 +124,7 @@ You should have put:
   <key-name> : choice { <argument> }
 but LaTeX did not find an <argument>.
 ! Package xtemplate Error: The key type 'function' requires an argument on
-(xtemplate)                line 141.
+(xtemplate)                line 140.
 For immediate help type H <return>.
  ...                                              
 l. ...}
@@ -134,7 +132,7 @@ You should have put:
   <key-name> : function { <argument> }
 but LaTeX did not find an <argument>.
 ! Package xtemplate Error: The key type 'instance' requires an argument on
-(xtemplate)                line 141.
+(xtemplate)                line 140.
 For immediate help type H <return>.
  ...                                              
 l. ...}
@@ -180,7 +178,7 @@ possible: the number of arguments must agree.
 TEST 8: Same template name different types
 ============================================================
 Package xtemplate Info: Declaring object type 'ok' taking 3 argument(s) on
-(xtemplate)             line 177.
+(xtemplate)             line 176.
 Package xtemplate Info: Declaring object type 'also-ok' taking 2 argument(s)
 (xtemplate)             on line ....
 Defining \template defaults > ok/tname on line ...
@@ -305,7 +303,7 @@ TEST 15: Testing code interface: choices
 TEST 16: Testing interfaces in document preamble
 ============================================================
 Package xtemplate Info: Declaring object type 'test' taking 1 argument(s) on
-(xtemplate)             line 330.
+(xtemplate)             line 328.
 Defining key template/test/tname3/key on line ...
 Defining key template/test/tname3/key/unknown on line ...
 Defining key template/test/tname3/key/A on line ...
diff --git a/l3packages/xtemplate/xtemplate.dtx b/l3packages/xtemplate/xtemplate.dtx
index 7b05992c6..52f2d5959 100644
--- a/l3packages/xtemplate/xtemplate.dtx
+++ b/l3packages/xtemplate/xtemplate.dtx
@@ -4,7 +4,7 @@
 %
 % Copyright (C) 1999 Frank Mittelbach, Chris Rowley, David Carlisle
 %           (C) 2004-2010 Frank Mittelbach, The LaTeX Project
-%           (C) 2011-2022 The LaTeX Project
+%           (C) 2011-2023 The LaTeX Project
 %\
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -244,8 +244,6 @@
 %       boolean    & \texttt{true} or \texttt{false}            \\
 %       choice\Arg{choices}
 %         & A list of pre-defined \meta{choices} \\
-%       code
-%         & Generalised key type: use |#1| as the input to the key \\
 %       commalist  & A comma-separated list                        \\
 %       function\Arg{$N$}
 %         & A function definition with $N$ arguments
@@ -331,8 +329,6 @@
 %       choice
 %         & List of choice implementations
 %         (see Section~\ref{sec:choices-key}) \\
-%       code
-%         & \meta{code} using |#1| as input to the key \\
 %       commalist  & Comma list, \emph{e.g}.~\cs{l_tmpa_clist}           \\
 %       function
 %         & Function taking $N$ arguments, \emph{e.g}.~\cs{use_i:nn}     \\
@@ -1448,16 +1444,16 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_store_value_code:n, \@@_store_value_choice:n,
+% \begin{macro}{\@@_store_value:n, \@@_store_value_choice:n,
 %   \@@_store_value_function:n, \@@_store_value_instance:n}
 %   With no need to worry about delayed evaluation, these keytypes all
 %   just store the input directly.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_store_value_code:n #1
+\cs_new_protected:Npn \@@_store_value:n #1
   { \prop_put:Non \l_@@_values_prop \l_@@_key_name_tl {#1} }
-\cs_new_eq:NN \@@_store_value_choice:n    \@@_store_value_code:n
-\cs_new_eq:NN \@@_store_value_function:n  \@@_store_value_code:n
-\cs_new_eq:NN \@@_store_value_instance:n  \@@_store_value_code:n
+\cs_new_eq:NN \@@_store_value_choice:n    \@@_store_value:n
+\cs_new_eq:NN \@@_store_value_function:n  \@@_store_value:n
+\cs_new_eq:NN \@@_store_value_instance:n  \@@_store_value:n
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1612,16 +1608,6 @@
     \str_case:VnF \l_@@_keytype_tl
       {
         { choice } { \@@_implement_choices:nn {#1} {#3} }
-        { code }
-          {
-            \@@_parse_vars_elt_key:nn {#1}
-              {
-                .cs_ \str_if_eq:nnT {#1} { global } { g }
-                   set_protected:Np = \exp_not:N #3
-              }
-            \prop_put:Non \l_@@_vars_prop
-              \l_@@_key_name_tl {#2#3}
-          }
         { function }
           {
             \cs_if_exist:NF #3
@@ -2206,26 +2192,6 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\@@_assign_code:}
-% \begin{macro}{\@@_assign_code:n}
-%   Assigning general code to a key needs a scratch function to be created
-%   and run when \cs{AssignTemplateKeys} is called. So the appropriate
-%   definition then use is created in the token list variable.
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_code:
-  {
-    \tl_put_right:Nx \l_@@_assignments_tl
-      {
-        \cs_set_protected:Npn \@@_assign_code:n \exp_not:n {##1}
-          { \exp_not:o \l_@@_var_tl }
-        \@@_assign_code:n { \exp_not:o \l_@@_value_tl }
-      }
-  }
-\cs_new_protected:Npn \@@_assign_code:n #1 { }
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
 % \begin{macro}{\@@_assign_function:}
 % \begin{macro}{\@@_assign_function_aux:N}
 %   This looks a bit messy but is only actually one function.
@@ -2751,7 +2717,6 @@
     Valid~key-types~are:\\
     -~boolean;\\
     -~choice;\\
-    -~code;\\
     -~commalist;\\
     -~function;\\
     -~instance;\\





More information about the latex3-commits mailing list.