-
Notifications
You must be signed in to change notification settings - Fork 178
/
l3basics.dtx
3324 lines (3324 loc) · 126 KB
/
l3basics.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
%% File: l3basics.dtx
%
% Copyright (C) 1990-2022 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
% license or (at your option) any later version. The latest version
% of this license is in the file
%
% https://www.latex-project.org/lppl.txt
%
% This file is part of the "l3kernel bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
% https://github.com/latex3/latex3
%
% for those people who are interested.
%
%<*driver>
\documentclass[full,kernel]{l3doc}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{^^A
% The \pkg{l3basics} package\\ Basic definitions^^A
% }
%
% \author{^^A
% The \LaTeX{} Project\thanks
% {^^A
% E-mail:
% \href{mailto:latex-team@latex-project.org}
% {latex-team@latex-project.org}^^A
% }^^A
% }
%
% \date{Released 2022-08-30}
%
% \maketitle
%
% \begin{documentation}
%
% As the name suggest this package holds some basic definitions which
% are needed by most or all other packages in this set.
%
% Here we describe those functions that are used all over the place. With
% that we mean functions dealing with the construction and testing of
% control sequences. Furthermore the basic parts of conditional
% processing are covered; conditional processing dealing with specific
% data types is described in the modules specific for the respective
% data types.
%
% \section{No operation functions}
%
% \begin{function}[EXP]{\prg_do_nothing:}
% \begin{syntax}
% \cs{prg_do_nothing:}
% \end{syntax}
% An expandable function which does nothing at all: leaves nothing
% in the input stream after a single expansion.
% \end{function}
%
% \begin{function}{\scan_stop:}
% \begin{syntax}
% \cs{scan_stop:}
% \end{syntax}
% A non-expandable function which does nothing. Does not vanish on
% expansion but produces no typeset output.
% \end{function}
%
% \section{Grouping material}
%
% \begin{function}{\group_begin:, \group_end:}
% \begin{syntax}
% \cs{group_begin:}
% \cs{group_end:}
% \end{syntax}
% These functions begin and end a group for definition purposes.
% Assignments are local to groups unless carried out in a global
% manner. (A small number of exceptions to this rule will be noted
% as necessary elsewhere in this document.) Each \cs{group_begin:}
% must be matched by a \cs{group_end:}, although this does not have
% to occur within the same function. Indeed, it is often necessary
% to start a group within one function and finish it within another,
% for example when seeking to use non-standard category codes.
% \end{function}
%
% \begin{function}{\group_insert_after:N}
% \begin{syntax}
% \cs{group_insert_after:N} \meta{token}
% \end{syntax}
% Adds \meta{token} to the list of \meta{tokens} to be inserted
% when the current group level ends. The list of \meta{tokens} to be
% inserted is empty at the beginning of a group: multiple
% applications of \cs{group_insert_after:N} may be used to build
% the inserted list one \meta{token} at a time. The current group
% level may be closed by a \cs{group_end:} function or by a token
% with category code $2$ (close-group), namely a ^^A{
% |}| if standard category codes apply.
% \end{function}
%
% \begin{function}[added = 2021-05-11]{\group_show_list:, \group_log_list:}
% \begin{syntax}
% \cs{group_show_list:}
% \cs{group_log_list:}
% \end{syntax}
% Display (to the terminal or log file) a list of the groups that are
% currently opened. This is intended for tracking down problems.
% \begin{texnote}
% This is a wrapper around the \tn{showgroups} primitive.
% \end{texnote}
% \end{function}
%
% \section{Control sequences and functions}
%
% As \TeX{} is a macro language, creating new functions means
% creating macros. At point of use, a function is replaced by
% the replacement text (\enquote{code}) in which each parameter
% in the code (|#1|, |#2|, \emph{etc.}) is replaced the appropriate
% arguments absorbed by the function. In the following, \meta{code}
% is therefore used as a shorthand for \enquote{replacement text}.
%
% Functions which are not \enquote{protected} are fully expanded
% inside an \texttt{x} expansion. In contrast, \enquote{protected}
% functions are not expanded within \texttt{x} expansions.
%
% \subsection{Defining functions}
%
% Functions can be created with no requirement that they are declared
% first (in contrast to variables, which must always be declared).
% Declaring a function before setting up the code means that the name
% chosen is checked and an error raised if it is already in use.
% The name of a function can be checked at the point of definition using
% the \cs[no-index]{cs_new\ldots} functions: this is recommended for all
% functions which are defined for the first time.
%
% There are three ways to define new functions.
% All classes define a function to expand to the substitution text.
% Within the substitution text the actual parameters are substituted
% for the formal parameters (|#1|, |#2|, \ldots).
% \begin{description}
% \item[\texttt{new}]
% Create a new function with the \texttt{new} scope,
% such as \cs{cs_new:Npn}. The definition is global and results in
% an error if it is already defined.
% \item[\texttt{set}]
% Create a new function with the \texttt{set} scope,
% such as \cs{cs_set:Npn}. The definition is restricted to the current
% \TeX{} group and does not result in an error if the function is already
% defined.
% \item[\texttt{gset}]
% Create a new function with the \texttt{gset} scope,
% such as \cs{cs_gset:Npn}. The definition is global and
% does not result in an error if the function is already defined.
% \end{description}
%
% Within each set of scope there are different ways to define a function.
% The differences depend on restrictions on the actual parameters and
% the expandability of the resulting function.
% \begin{description}
% \item[\texttt{nopar}]
% Create a new function with the \texttt{nopar} restriction,
% such as \cs{cs_set_nopar:Npn}. The parameter may not contain
% \cs{par} tokens.
% \item[\texttt{protected}]
% Create a new function with the \texttt{protected} restriction,
% such as \cs{cs_set_protected:Npn}. The parameter may contain
% \cs{par} tokens but the function will not expand within an
% \texttt{x}-type or \texttt{e}-type expansion.
% \end{description}
%
% Finally, the functions in
% Subsections~\ref{sec:l3basics:defining-new-function-1}~and
% \ref{sec:l3basics:defining-new-function-2} are primarily meant to define
% \emph{base functions} only. Base functions can only have the following
% argument specifiers:
% \begin{description}
% \item[|N| and |n|] No manipulation.
% \item[|T| and |F|] Functionally equivalent to |n| (you are actually
% encouraged to use the family of |\prg_new_conditional:| functions
% described in Section~\ref{sec:l3prg:new-conditional-functions}).
% \item[|p| and |w|] These are special cases.
% \end{description}
%
% The |\cs_new:| functions below (and friends) do not stop you from using
% other argument specifiers in your function names, but they do not handle
% expansion for you. You should define the base function and then use
% \cs{cs_generate_variant:Nn} to generate custom variants as described in
% Section~\ref{sec:l3expan:variants-method}.
%
% \subsection{Defining new functions using parameter text}
% \label{sec:l3basics:defining-new-function-1}
%
% \begin{function}{\cs_new:Npn, \cs_new:cpn, \cs_new:Npx, \cs_new:cpx}
% \begin{syntax}
% \cs{cs_new:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% The definition is global and an error results if the
% \meta{function} is already defined.
% \end{function}
%
% \begin{function}
% {
% \cs_new_nopar:Npn, \cs_new_nopar:cpn,
% \cs_new_nopar:Npx, \cs_new_nopar:cpx
% }
% \begin{syntax}
% \cs{cs_new_nopar:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% When the \meta{function} is used the \meta{parameters} absorbed
% cannot contain \cs{par} tokens. The definition is global and
% an error results if the \meta{function} is already defined.
% \end{function}
%
% \begin{function}
% {
% \cs_new_protected:Npn, \cs_new_protected:cpn,
% \cs_new_protected:Npx, \cs_new_protected:cpx
% }
% \begin{syntax}
% \cs{cs_new_protected:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% The \meta{function} will not expand within an \texttt{x}-type or
% or \texttt{e}-type
% argument. The definition is global and an error results if the
% \meta{function} is already defined.
% \end{function}
%
% \begin{function}
% {
% \cs_new_protected_nopar:Npn, \cs_new_protected_nopar:cpn ,
% \cs_new_protected_nopar:Npx, \cs_new_protected_nopar:cpx
% }
% \begin{syntax}
% \cs{cs_new_protected_nopar:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% When the \meta{function} is used the \meta{parameters} absorbed
% cannot contain \cs{par} tokens. The \meta{function} will not
% expand within an \texttt{x}-type or \texttt{e}-type argument. The definition is global
% and an error results if the \meta{function} is already defined.
% \end{function}
%
% \begin{function}{\cs_set:Npn, \cs_set:cpn, \cs_set:Npx, \cs_set:cpx}
% \begin{syntax}
% \cs{cs_set:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% The assignment of a meaning to the \meta{function} is restricted to
% the current \TeX{} group level.
% \end{function}
%
% \begin{function}
% {
% \cs_set_nopar:Npn, \cs_set_nopar:cpn,
% \cs_set_nopar:Npx, \cs_set_nopar:cpx
% }
% \begin{syntax}
% \cs{cs_set_nopar:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% When the \meta{function} is used the \meta{parameters} absorbed
% cannot contain \cs{par} tokens. The assignment of a meaning
% to the \meta{function} is restricted to the current \TeX{} group
% level.
% \end{function}
%
% \begin{function}
% {
% \cs_set_protected:Npn, \cs_set_protected:cpn,
% \cs_set_protected:Npx, \cs_set_protected:cpx
% }
% \begin{syntax}
% \cs{cs_set_protected:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% The assignment of a meaning to the \meta{function} is restricted to
% the current \TeX{} group level. The \meta{function} will
% not expand within an \texttt{x}-type or \texttt{e}-type argument.
% \end{function}
%
% \begin{function}
% {
% \cs_set_protected_nopar:Npn, \cs_set_protected_nopar:cpn ,
% \cs_set_protected_nopar:Npx, \cs_set_protected_nopar:cpx ,
% }
% \begin{syntax}
% \cs{cs_set_protected_nopar:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% When the \meta{function} is used the \meta{parameters} absorbed
% cannot contain \cs{par} tokens. The assignment of a meaning
% to the \meta{function} is restricted to the current \TeX{} group
% level. The \meta{function} will not expand within an
% \texttt{x}-type or \texttt{e}-type argument.
% \end{function}
%
% \begin{function}{\cs_gset:Npn, \cs_gset:cpn, \cs_gset:Npx, \cs_gset:cpx}
% \begin{syntax}
% \cs{cs_gset:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Globally sets \meta{function} to expand to \meta{code} as replacement
% text. Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% The assignment of a meaning to the \meta{function} is \emph{not}
% restricted to the current \TeX{} group level: the assignment is
% global.
% \end{function}
%
% \begin{function}
% {
% \cs_gset_nopar:Npn, \cs_gset_nopar:cpn,
% \cs_gset_nopar:Npx, \cs_gset_nopar:cpx
% }
% \begin{syntax}
% \cs{cs_gset_nopar:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Globally sets \meta{function} to expand to \meta{code} as replacement
% text. Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% When the \meta{function} is used the \meta{parameters} absorbed
% cannot contain \cs{par} tokens. The assignment of a meaning to the
% \meta{function} is \emph{not} restricted to the current \TeX{}
% group level: the assignment is global.
% \end{function}
%
% \begin{function}
% {
% \cs_gset_protected:Npn, \cs_gset_protected:cpn,
% \cs_gset_protected:Npx, \cs_gset_protected:cpx
% }
% \begin{syntax}
% \cs{cs_gset_protected:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Globally sets \meta{function} to expand to \meta{code} as replacement
% text. Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% The assignment of a meaning to the \meta{function} is \emph{not}
% restricted to the current \TeX{} group level: the assignment is
% global. The \meta{function} will not expand within an
% \texttt{x}-type or \texttt{e}-type argument.
% \end{function}
%
% \begin{function}
% {
% \cs_gset_protected_nopar:Npn, \cs_gset_protected_nopar:cpn,
% \cs_gset_protected_nopar:Npx, \cs_gset_protected_nopar:cpx
% }
% \begin{syntax}
% \cs{cs_gset_protected_nopar:Npn} \meta{function} \meta{parameters} \Arg{code}
% \end{syntax}
% Globally sets \meta{function} to expand to \meta{code} as replacement
% text. Within the \meta{code}, the \meta{parameters} (|#1|, |#2|,
% \emph{etc.}) will be replaced by those absorbed by the function.
% When the \meta{function} is used the \meta{parameters} absorbed
% cannot contain \cs{par} tokens. The assignment of a meaning to the
% \meta{function} is \emph{not} restricted to the current \TeX{}
% group level: the assignment is global. The \meta{function} will
% not expand within an \texttt{x}-type or \texttt{e}-type argument.
% \end{function}
%
% \subsection{Defining new functions using the signature}
% \label{sec:l3basics:defining-new-function-2}
%
% \begin{function}
% {
% \cs_new:Nn, \cs_new:cn,
% \cs_new:Nx, \cs_new:cx
% }
% \begin{syntax}
% \cs{cs_new:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. The definition is global and
% an error results if the \meta{function} is already defined.
% \end{function}
%
% \begin{function}
% {
% \cs_new_nopar:Nn, \cs_new_nopar:cn,
% \cs_new_nopar:Nx, \cs_new_nopar:cx
% }
% \begin{syntax}
% \cs{cs_new_nopar:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. When the \meta{function} is used the \meta{parameters}
% absorbed cannot contain \cs{par} tokens. The definition is global and
% an error results if the \meta{function} is already defined.
% \end{function}
%
% \begin{function}
% {
% \cs_new_protected:Nn, \cs_new_protected:cn,
% \cs_new_protected:Nx, \cs_new_protected:cx
% }
% \begin{syntax}
% \cs{cs_new_protected:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. The \meta{function} will not expand within an \texttt{x}-type
% or \texttt{e}-type argument. The definition is global and
% an error results if the \meta{function} is already defined.
% \end{function}
%
% \begin{function}
% {
% \cs_new_protected_nopar:Nn, \cs_new_protected_nopar:cn,
% \cs_new_protected_nopar:Nx, \cs_new_protected_nopar:cx
% }
% \begin{syntax}
% \cs{cs_new_protected_nopar:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Creates \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. When the \meta{function} is used the \meta{parameters}
% absorbed cannot contain \cs{par} tokens. The \meta{function} will not
% expand within an \texttt{x}-type or \texttt{e}-type argument. The definition is global and
% an error results if the \meta{function} is already defined.
% \end{function}
%
% \begin{function}
% {
% \cs_set:Nn, \cs_set:cn,
% \cs_set:Nx, \cs_set:cx
% }
% \begin{syntax}
% \cs{cs_set:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function.
% The assignment of a meaning to the \meta{function} is restricted to
% the current \TeX{} group level.
% \end{function}
%
% \begin{function}
% {
% \cs_set_nopar:Nn, \cs_set_nopar:cn,
% \cs_set_nopar:Nx, \cs_set_nopar:cx
% }
% \begin{syntax}
% \cs{cs_set_nopar:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. When the \meta{function} is used the \meta{parameters}
% absorbed cannot contain \cs{par} tokens.
% The assignment of a meaning to the \meta{function} is restricted to
% the current \TeX{} group level.
% \end{function}
%
% \begin{function}
% {
% \cs_set_protected:Nn, \cs_set_protected:cn,
% \cs_set_protected:Nx, \cs_set_protected:cx
% }
% \begin{syntax}
% \cs{cs_set_protected:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. The \meta{function} will not expand within an \texttt{x}-type
% or \texttt{e}-type argument.
% The assignment of a meaning to the \meta{function} is restricted to
% the current \TeX{} group level.
% \end{function}
%
% \begin{function}
% {
% \cs_set_protected_nopar:Nn, \cs_set_protected_nopar:cn,
% \cs_set_protected_nopar:Nx, \cs_set_protected_nopar:cx
% }
% \begin{syntax}
% \cs{cs_set_protected_nopar:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. When the \meta{function} is used the \meta{parameters}
% absorbed cannot contain \cs{par} tokens. The \meta{function} will not
% expand within an \texttt{x}-type or \texttt{e}-type argument.
% The assignment of a meaning to the \meta{function} is restricted to
% the current \TeX{} group level.
% \end{function}
%
% \begin{function}
% {
% \cs_gset:Nn, \cs_gset:cn,
% \cs_gset:Nx, \cs_gset:cx
% }
% \begin{syntax}
% \cs{cs_gset:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function.
% The assignment of a meaning to the \meta{function} is global.
% \end{function}
%
% \begin{function}
% {
% \cs_gset_nopar:Nn, \cs_gset_nopar:cn,
% \cs_gset_nopar:Nx, \cs_gset_nopar:cx
% }
% \begin{syntax}
% \cs{cs_gset_nopar:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. When the \meta{function} is used the \meta{parameters}
% absorbed cannot contain \cs{par} tokens.
% The assignment of a meaning to the \meta{function} is global.
% \end{function}
%
% \begin{function}
% {
% \cs_gset_protected:Nn, \cs_gset_protected:cn,
% \cs_gset_protected:Nx, \cs_gset_protected:cx
% }
% \begin{syntax}
% \cs{cs_gset_protected:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. The \meta{function} will not expand within an \texttt{x}-type
% or \texttt{e}-type argument.
% The assignment of a meaning to the \meta{function} is global.
% \end{function}
%
% \begin{function}
% {
% \cs_gset_protected_nopar:Nn, \cs_gset_protected_nopar:cn,
% \cs_gset_protected_nopar:Nx, \cs_gset_protected_nopar:cx
% }
% \begin{syntax}
% \cs{cs_gset_protected_nopar:Nn} \meta{function} \Arg{code}
% \end{syntax}
% Sets \meta{function} to expand to \meta{code} as replacement text.
% Within the \meta{code}, the number of \meta{parameters} is detected
% automatically from the function signature. These \meta{parameters}
% (|#1|, |#2|, \emph{etc.}) will be replaced by those absorbed by the
% function. When the \meta{function} is used the \meta{parameters}
% absorbed cannot contain \cs{par} tokens. The \meta{function} will not
% expand within an \texttt{x}-type or \texttt{e}-type argument.
% The assignment of a meaning to the \meta{function} is global.
% \end{function}
%
% \begin{function}[updated = 2012-01-14]
% {
% \cs_generate_from_arg_count:NNnn,
% \cs_generate_from_arg_count:cNnn,
% \cs_generate_from_arg_count:Ncnn
% }
% \begin{syntax}
% \cs{cs_generate_from_arg_count:NNnn} \meta{function} \meta{creator} \Arg{number} \Arg{code}
% \end{syntax}
% Uses the \meta{creator} function (which should have signature
% |Npn|, for example \cs{cs_new:Npn}) to define a \meta{function}
% which takes \meta{number} arguments and has \meta{code} as
% replacement text. The \meta{number} of arguments is an integer expression,
% evaluated as detailed for \cs{int_eval:n}.
% \end{function}
%
% \subsection{Copying control sequences}
%
% Control sequences (not just functions as defined above) can
% be set to have the same meaning using the functions described
% here. Making two control sequences equivalent means that the
% second control sequence is a \emph{copy} of the first (rather than
% a pointer to it). Thus the old and new control sequence are not
% tied together: changes to one are not reflected in the other.
%
% In the following text \enquote{cs} is used as an abbreviation for
% \enquote{control sequence}.
%
% \begin{function}
% {\cs_new_eq:NN, \cs_new_eq:Nc, \cs_new_eq:cN, \cs_new_eq:cc}
% \begin{syntax}
% \cs{cs_new_eq:NN} \meta{cs_1} \meta{cs_2}
% \cs{cs_new_eq:NN} \meta{cs_1} \meta{token}
% \end{syntax}
% Globally creates \meta{control sequence_1} and sets it to have the same
% meaning as \meta{control sequence_2} or <token>.
% The second control sequence may
% subsequently be altered without affecting the copy.
% \end{function}
%
% \begin{function}
% {\cs_set_eq:NN, \cs_set_eq:Nc, \cs_set_eq:cN, \cs_set_eq:cc}
% \begin{syntax}
% \cs{cs_set_eq:NN} \meta{cs_1} \meta{cs_2}
% \cs{cs_set_eq:NN} \meta{cs_1} \meta{token}
% \end{syntax}
% Sets \meta{control sequence_1} to have the same meaning as
% \meta{control sequence_2} (or <token>).
% The second control sequence may subsequently be
% altered without affecting the copy. The assignment of a meaning
% to the \meta{control sequence_1} is restricted to the current
% \TeX{} group level.
% \end{function}
%
% \begin{function}
% {\cs_gset_eq:NN, \cs_gset_eq:Nc, \cs_gset_eq:cN, \cs_gset_eq:cc}
% \begin{syntax}
% \cs{cs_gset_eq:NN} \meta{cs_1} \meta{cs_2}
% \cs{cs_gset_eq:NN} \meta{cs_1} \meta{token}
% \end{syntax}
% Globally sets \meta{control sequence_1} to have the same meaning as
% \meta{control sequence_2} (or <token>).
% The second control sequence may subsequently be
% altered without affecting the copy. The assignment of a meaning to
% the \meta{control sequence_1} is \emph{not} restricted to the current
% \TeX{} group level: the assignment is global.
% \end{function}
%
% \subsection{Deleting control sequences}
%
% There are occasions where control sequences need to be deleted.
% This is handled in a very simple manner.
%
% \begin{function}[updated = 2011-09-15]{\cs_undefine:N, \cs_undefine:c}
% \begin{syntax}
% \cs{cs_undefine:N} \meta{control sequence}
% \end{syntax}
% Sets \meta{control sequence} to be globally undefined.
% \end{function}
%
% \subsection{Showing control sequences}
%
% \begin{function}[EXP, updated = 2011-12-22]{\cs_meaning:N, \cs_meaning:c}
% \begin{syntax}
% \cs{cs_meaning:N} \meta{control sequence}
% \end{syntax}
% This function expands to the \emph{meaning} of the \meta{control sequence}
% control sequence. For a macro, this includes the \meta{replacement text}.
% \begin{texnote}
% This is \TeX{}'s \tn{meaning} primitive.
% For tokens that are not control sequences, it is more logical to
% use \cs{token_to_meaning:N}.
% The \texttt{c} variant correctly reports undefined arguments.
% \end{texnote}
% \end{function}
%
% \begin{function}[updated = 2017-02-14]{\cs_show:N, \cs_show:c}
% \begin{syntax}
% \cs{cs_show:N} \meta{control sequence}
% \end{syntax}
% Displays the definition of the \meta{control sequence} on the
% terminal.
% \begin{texnote}
% This is similar to the \TeX{} primitive \tn{show}, wrapped to a
% fixed number of characters per line.
% \end{texnote}
% \end{function}
%
% \begin{function}[added = 2014-08-22, updated = 2017-02-14]{\cs_log:N, \cs_log:c}
% \begin{syntax}
% \cs{cs_log:N} \meta{control sequence}
% \end{syntax}
% Writes the definition of the \meta{control sequence} in the log
% file. See also \cs{cs_show:N} which displays the result in the
% terminal.
% \end{function}
%
% \subsection{Converting to and from control sequences}
%
% \begin{function}[EXP]{\use:c}
% \begin{syntax}
% \cs{use:c} \Arg{control sequence name}
% \end{syntax}
% Expands the \meta{control sequence name} until only characters
% remain, and then converts this into a control sequence. This process
% requires two expansions. As in other \texttt{c}-type arguments the
% \meta{control sequence name} must, when fully expanded, consist of
% character tokens, typically a mixture of category code $10$ (space),
% $11$ (letter) and $12$ (other).
% \end{function}
%
% As an example of the \cs{use:c} function, both
% \begin{verbatim}
% \use:c { a b c }
% \end{verbatim}
% and
% \begin{verbatim}
% \tl_new:N \l_my_tl
% \tl_set:Nn \l_my_tl { a b c }
% \use:c { \tl_use:N \l_my_tl }
% \end{verbatim}
% would be equivalent to
% \begin{verbatim}
% \abc
% \end{verbatim}
% after two expansions of \cs{use:c}.
%
% \begin{function}[noTF, EXP, added = 2012-11-10]
% {\cs_if_exist_use:N, \cs_if_exist_use:c}
% \begin{syntax}
% \cs{cs_if_exist_use:N} \meta{control sequence}
% \cs{cs_if_exist_use:NTF} \meta{control sequence} \Arg{true code} \Arg{false code}
% \end{syntax}
% Tests whether the \meta{control sequence} is currently defined
% according to the conditional \cs{cs_if_exist:NTF}
% (whether as a function or another control sequence type), and if it
% is inserts the \meta{control sequence} into the input stream followed
% by the \meta{true code}. Otherwise the \meta{false code} is used.
% \end{function}
%
% \begin{function}[EXP]{\cs:w, \cs_end:}
% \begin{syntax}
% \cs{cs:w} \meta{control sequence name} \cs{cs_end:}
% \end{syntax}
% Converts the given \meta{control sequence name} into a single
% control sequence token. This process requires one expansion.
% The content for \meta{control sequence name} may be literal
% material or from other expandable functions. The
% \meta{control sequence name} must, when fully expanded, consist
% of character tokens which are not active: typically
% of category code $10$ (space), $11$ (letter)
% or $12$ (other), or a mixture of these.
% \begin{texnote}
% These are the \TeX{} primitives \tn{csname} and \tn{endcsname}.
% \end{texnote}
% \end{function}
%
% As an example of the \cs{cs:w} and \cs{cs_end:} functions, both
% \begin{verbatim}
% \cs:w a b c \cs_end:
% \end{verbatim}
% and
% \begin{verbatim}
% \tl_new:N \l_my_tl
% \tl_set:Nn \l_my_tl { a b c }
% \cs:w \tl_use:N \l_my_tl \cs_end:
% \end{verbatim}
% would be equivalent to
% \begin{verbatim}
% \abc
% \end{verbatim}
% after one expansion of \cs{cs:w}.
%
% \begin{function}[EXP]{\cs_to_str:N}
% \begin{syntax}
% \cs{cs_to_str:N} \meta{control sequence}
% \end{syntax}
% Converts the given \meta{control sequence} into a series of
% characters with category code $12$ (other), except spaces,
% of category code $10$. The result does \emph{not} include
% the current escape token, contrarily to \cs{token_to_str:N}.
% Full expansion of this function requires exactly $2$ expansion
% steps, and so an \texttt{x}-type or \texttt{e}-type expansion, or two
% \texttt{o}-type expansions are required to
% convert the \meta{control sequence} to a sequence of characters
% in the input stream. In most cases, an \texttt{f}-expansion
% is correct as well, but this loses a space at the start
% of the result.
% \end{function}
%
% \section{Analysing control sequences}
%
% \begin{function}[EXP, added = 2018-04-06]{\cs_split_function:N}
% \begin{syntax}
% \cs{cs_split_function:N} \meta{function}
% \end{syntax}
% Splits the \meta{function} into the \meta{name} (\emph{i.e.}~the part
% before the colon) and the \meta{signature} (\emph{i.e.}~after the colon).
% This information is then placed in the input stream
% in three parts: the \meta{name}, the
% \meta{signature} and a logic token indicating if a colon was found
% (to differentiate variables from function names). The \meta{name}
% does not include the escape character, and both the \meta{name} and
% \meta{signature} are made up of tokens with category code $12$
% (other).
% \end{function}
%
% The next three functions decompose \TeX{} macros into their
% constituent parts: if the \meta{token} passed is not a macro then no
% decomposition can occur. In the latter case, all three functions leave
% \cs{scan_stop:} in the input stream.
%
% \begin{function}[EXP, added = 2019-02-27]{\cs_prefix_spec:N}
% \begin{syntax}
% \cs{cs_prefix_spec:N} \meta{token}
% \end{syntax}
% If the \meta{token} is a macro, this function leaves the applicable
% \TeX{} prefixes in input stream as a string of tokens of category
% code $12$ (with spaces having category code $10$). Thus for example
% \begin{verbatim}
% \cs_set:Npn \next:nn #1#2 { x #1~y #2 }
% \cs_prefix_spec:N \next:nn
% \end{verbatim}
% leaves |\long| in the input stream. If the \meta{token} is
% not a macro then \cs{scan_stop:} is left in the input stream.
% \begin{texnote}
% The prefix can be empty, |\long|, |\protected| or
% |\protected\long| with backslash replaced by the current escape
% character.
% \end{texnote}
% \end{function}
%
% \begin{function}[EXP, added = 2022-06-24]{\cs_parameter_spec:N}
% \begin{syntax}
% \cs{cs_parameter_spec:N} \meta{token}
% \end{syntax}
% If the \meta{token} is a macro, this function leaves the primitive
% \TeX{} parameter specification in input stream as a string of
% character tokens of category code $12$ (with spaces having category
% code $10$). Thus for example
% \begin{verbatim}
% \cs_set:Npn \next:nn #1#2 { x #1 y #2 }
% \cs_parameter_spec:N \next:nn
% \end{verbatim}
% leaves |#1#2| in the input stream. If the \meta{token} is
% not a macro then \cs{scan_stop:} is left in the input stream.
% \begin{texnote}
% If the parameter specification contains the string |->|, then the
% function produces incorrect results.
% \end{texnote}
% \end{function}
%
% \begin{function}[EXP, added = 2019-02-27]{\cs_replacement_spec:N}
% \begin{syntax}
% \cs{cs_replacement_spec:N} \meta{token}
% \end{syntax}
% If the \meta{token} is a macro, this function leaves the replacement
% text in input stream as a string of character tokens of category
% code $12$ (with spaces having category code $10$). Thus for example
% \begin{verbatim}
% \cs_set:Npn \next:nn #1#2 { x #1~y #2 }
% \cs_replacement_spec:N \next:nn
% \end{verbatim}
% leaves \verb*|x#1 y#2| in the input stream. If the \meta{token} is
% not a macro then \cs{scan_stop:} is left in the input stream.
% \begin{texnote}
% If the parameter specification contains the string |->|, then the
% function produces incorrect results.
% \end{texnote}
% \end{function}
%
% \section{Using or removing tokens and arguments}
%
% Tokens in the input can be read and used or read and discarded.
% If one or more tokens are wrapped in braces then when absorbing them
% the outer set is removed. At the same time, the category code
% of each token is set when the token is read by a function (if it
% is read more than once, the category code is determined by
% the situation in force when first function absorbs the token).
%
% \begin{function}[EXP]{\use:n, \use:nn, \use:nnn, \use:nnnn}
% \begin{syntax}
% \cs{use:n} \Arg{group_1}
% \cs{use:nn} \Arg{group_1} \Arg{group_2}
% \cs{use:nnn} \Arg{group_1} \Arg{group_2} \Arg{group_3}
% \cs{use:nnnn} \Arg{group_1} \Arg{group_2} \Arg{group_3} \Arg{group_4}
% \end{syntax}
% As illustrated, these functions absorb between one and four
% arguments, as indicated by the argument specifier. The braces
% surrounding each argument are removed and the remaining tokens are
% left in the input stream. The category code of these tokens is
% also fixed by this process (if it has not already been by some
% other absorption). All of these functions require only a single
% expansion to operate, so that one expansion of
% \begin{verbatim}
% \use:nn { abc } { { def } }
% \end{verbatim}
% results in the input stream containing
% \begin{verbatim}
% abc { def }
% \end{verbatim}
% \emph{i.e.} only the outer braces are removed.
% \begin{texnote}
% The \cs{use:n} function is equivalent to \LaTeXe{}'s \tn{@firstofone}.
% \end{texnote}
% \end{function}
%
% \begin{function}[EXP]{\use_i:nn, \use_ii:nn}
% \begin{syntax}
% \cs{use_i:nn} \Arg{arg_1} \Arg{arg_2}
% \end{syntax}
% These functions absorb two arguments from the input stream. The function
% \cs{use_i:nn} discards the second argument, and leaves the content
% of the first argument in the input stream. \cs{use_ii:nn} discards
% the first argument and leaves the content of the second argument in
% the input stream.
% The category code
% of these tokens is also fixed (if it has not already been by
% some other absorption). A single expansion is needed for the
% functions to take effect.
% \begin{texnote}
% These are equivalent to \LaTeXe{}'s \tn{@firstoftwo} and
% \tn{@secondoftwo}.
% \end{texnote}
% \end{function}
%
% \begin{function}[EXP]{\use_i:nnn, \use_ii:nnn, \use_iii:nnn}
% \begin{syntax}
% \cs{use_i:nnn} \Arg{arg_1} \Arg{arg_2} \Arg{arg_3}
% \end{syntax}
% These functions absorb three arguments from the input stream. The
% function \cs{use_i:nnn} discards the second and third arguments, and
% leaves the content of the first argument in the input stream.
% \cs{use_ii:nnn} and \cs{use_iii:nnn} work similarly, leaving the
% content of second or third arguments in the input stream, respectively.
% The category code
% of these tokens is also fixed (if it has not already been by
% some other absorption). A single expansion is needed for the
% functions to take effect.
% \end{function}
%
% \begin{function}[EXP]
% {\use_i:nnnn, \use_ii:nnnn, \use_iii:nnnn, \use_iv:nnnn}
% \begin{syntax}
% \cs{use_i:nnnn} \Arg{arg_1} \Arg{arg_2} \Arg{arg_3} \Arg{arg_4}
% \end{syntax}
% These functions absorb four arguments from the input stream. The
% function \cs{use_i:nnnn} discards the second, third and fourth
% arguments, and leaves the content of the first argument in the input
% stream.
% \cs{use_ii:nnnn}, \cs{use_iii:nnnn} and \cs{use_iv:nnnn} work similarly,
% leaving the content of second, third or fourth arguments in the input
% stream, respectively. The category code
% of these tokens is also fixed (if it has not already been by
% some other absorption). A single expansion is needed for the
% functions to take effect.
% \end{function}
%
% \begin{function}[EXP]{\use_i_ii:nnn}
% \begin{syntax}
% \cs{use_i_ii:nnn} \Arg{arg_1} \Arg{arg_2} \Arg{arg_3}
% \end{syntax}
% This function absorbs three arguments and leaves the content of the
% first and second in the input stream. The category code of
% these tokens is also fixed (if it has not already been by
% some other absorption). A single expansion is needed for the
% function to take effect. An example:
% \begin{verbatim}
% \use_i_ii:nnn { abc } { { def } } { ghi }
% \end{verbatim}
% results in the input stream containing
% \begin{verbatim}
% abc { def }
% \end{verbatim}
% \emph{i.e.} the outer braces are removed and the third group
% is removed.
% \end{function}
%
% \begin{function}[EXP, added = 2019-06-02]{\use_ii_i:nn}
% \begin{syntax}