| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: expl3.dtx |
| 4 |
% |
| 5 |
% Copyright (C) 1990-2026 The LaTeX Project |
| 6 |
% |
| 7 |
% It may be distributed and/or modified under the conditions of the |
| 8 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 9 |
% license or (at your option) any later version. The latest version |
| 10 |
% of this license is in the file |
| 11 |
% |
| 12 |
% https://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% This file is part of the "l3kernel bundle" (The Work in LPPL) |
| 15 |
% and all files in that bundle must be distributed together. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/latex3/latex3 |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
\def\ExplFileDate{2026-05-15}% |
| 26 |
%<*driver> |
| 27 |
\documentclass[full]{l3doc} |
| 28 |
\usepackage{graphicx} |
| 29 |
\begin{document} |
| 30 |
\DocInput{\jobname.dtx} |
| 31 |
\end{document} |
| 32 |
%</driver> |
| 33 |
% \fi |
| 34 |
% |
| 35 |
% \providecommand\acro[1]{\textsc{\MakeLowercase{#1}}} |
| 36 |
% \newenvironment{arg-description}{% |
| 37 |
% \begin{itemize}\def\makelabel##1{\hss\llap{\bfseries##1}}}{\end{itemize}} |
| 38 |
% |
| 39 |
% \title{^^A |
| 40 |
% The \pkg{expl3} package and \LaTeX3 programming^^A |
| 41 |
% } |
| 42 |
% |
| 43 |
% \author{^^A |
| 44 |
% The \LaTeX{} Project\thanks |
| 45 |
% {^^A |
| 46 |
% E-mail: |
| 47 |
% \href{mailto:[email protected]} |
| 48 |
% {[email protected]}^^A |
| 49 |
% }^^A |
| 50 |
% } |
| 51 |
% |
| 52 |
% \date{Released 2026-05-15} |
| 53 |
% |
| 54 |
% \maketitle |
| 55 |
% |
| 56 |
% \begin{documentation} |
| 57 |
% |
| 58 |
% \begin{abstract} |
| 59 |
% |
| 60 |
% This document gives an introduction to a new set of programming |
| 61 |
% conventions that have been designed to meet the requirements of |
| 62 |
% implementing large scale \TeX{} macro programming projects such as |
| 63 |
% \LaTeX{}. These programming conventions are the base layer of \LaTeX3. |
| 64 |
% |
| 65 |
% The main features of the system described are: |
| 66 |
% \begin{itemize} |
| 67 |
% \item classification of the macros (or, in \LaTeX{} terminology, |
| 68 |
% commands) into \LaTeX{} functions and \LaTeX{} parameters, and also |
| 69 |
% into modules containing related commands; |
| 70 |
% \item a systematic naming scheme based on these classifications; |
| 71 |
% \item a simple mechanism for controlling the expansion of a function's |
| 72 |
% arguments. |
| 73 |
% \end{itemize} |
| 74 |
% This system is being used as the basis for \TeX{} programming within |
| 75 |
% The \LaTeX{} Project. Note that the language is not intended for either |
| 76 |
% document mark-up or style specification. Instead, it is intended that |
| 77 |
% such features will be built on top of the conventions described here. |
| 78 |
% |
| 79 |
% This document is an introduction to the ideas behind the \pkg{expl3} |
| 80 |
% programming interface. For the complete documentation of the programming |
| 81 |
% layer provided by The \LaTeX{} Project, see the accompanying |
| 82 |
% \texttt{interface3} document. |
| 83 |
% |
| 84 |
% \end{abstract} |
| 85 |
% |
| 86 |
% \section{Introduction} |
| 87 |
% |
| 88 |
% The first step to develop a \LaTeX{} kernel beyond \LaTeXe{} is to |
| 89 |
% address how the underlying system is programmed. Rather than the |
| 90 |
% current mix of \LaTeX{} and \TeX{} macros, the \LaTeX3 system provides |
| 91 |
% its own consistent interface to all of the functions needed to |
| 92 |
% control \TeX{}. A key part of this work is to ensure that everything |
| 93 |
% is documented, so that \LaTeX{} programmers and users can work |
| 94 |
% efficiently without needing to be familiar with the internal nature |
| 95 |
% of the kernel or with plain \TeX{}. |
| 96 |
% |
| 97 |
% The \pkg{expl3} bundle provides this new programming interface for |
| 98 |
% \LaTeX{}. To make programming systematic, \LaTeX3 uses some very |
| 99 |
% different conventions to \LaTeXe{} or plain \TeX{}. As a result, |
| 100 |
% programmers starting with \LaTeX3 need to become familiar with |
| 101 |
% the syntax of the new language. |
| 102 |
% |
| 103 |
% The next section shows where this language fits into a complete |
| 104 |
% \TeX{}-based document processing system. We then describe the major |
| 105 |
% features of the syntactic structure of command names, including the |
| 106 |
% argument specification syntax used in function names. |
| 107 |
% |
| 108 |
% The practical ideas behind this argument syntax will be explained, |
| 109 |
% together with the expansion control mechanism and the interface |
| 110 |
% used to define variant forms of functions. |
| 111 |
% |
| 112 |
% As we shall demonstrate, the use of a structured naming scheme and of |
| 113 |
% variant forms for functions greatly improves the readability of the |
| 114 |
% code and hence also its reliability. Moreover, experience has shown |
| 115 |
% that the longer command names which result from the new syntax do not |
| 116 |
% make the process of \emph{writing} code significantly harder. |
| 117 |
% |
| 118 |
% \section{Languages and interfaces} |
| 119 |
% |
| 120 |
% It is possible to identify several distinct languages related to the |
| 121 |
% various interfaces that are needed in a \TeX{}-based document processing |
| 122 |
% system. This section looks at those we consider most important for |
| 123 |
% the \LaTeX3 system. |
| 124 |
% |
| 125 |
% \begin{description} |
| 126 |
% \item[Document mark-up] This comprises those commands (often called |
| 127 |
% tags) that are to embedded in the document (the |.tex| file). |
| 128 |
% |
| 129 |
% It is generally accepted that such mark-up should be essentially |
| 130 |
% \emph{declarative}. It may be traditional \TeX{}-based mark-up such |
| 131 |
% as \LaTeXe{}, as described in~\cite{A-W:LLa94} and~\cite{A-W:GMS94}, |
| 132 |
% or a mark-up language defined via \acro{HTML} or \acro{XML}. |
| 133 |
% |
| 134 |
% One problem with more traditional \TeX{} coding conventions (as |
| 135 |
% described in~\cite{A-W:K-TB}) is that the names and syntax of \TeX{}'s |
| 136 |
% primitive formatting commands are ingeniously designed to be |
| 137 |
% \enquote{natural} when used directly by the author as document mark-up |
| 138 |
% or in macros. Ironically, the ubiquity (and widely recognized |
| 139 |
% superiority) of logical mark-up has meant that such explicit |
| 140 |
% formatting commands are almost never needed in documents or in |
| 141 |
% author-defined macros. Thus they are used almost exclusively by |
| 142 |
% \TeX{} programmers to define higher-level commands, and their |
| 143 |
% idiosyncratic syntax is not at all popular with this community. |
| 144 |
% Moreover, many of them have names that could be very useful as |
| 145 |
% document mark-up tags were they not pre-empted as primitives |
| 146 |
% (\emph{e.g.}~\tn{box} or \tn{special}). |
| 147 |
% |
| 148 |
% \item[Designer interface] This relates a (human) typographic |
| 149 |
% designer's specification for a document to a program that |
| 150 |
% \enquote{formats |
| 151 |
% the document}. It should ideally use a declarative language that |
| 152 |
% facilitates expression of the relationship and spacing rules |
| 153 |
% specified for the layout of the various document elements. |
| 154 |
% |
| 155 |
% This language is not embedded in document text and it will be very |
| 156 |
% different in form to the document mark-up language. For \LaTeX{}, |
| 157 |
% this level was almost completely missing from \LaTeX{}2.09; \LaTeXe{} |
| 158 |
% made some improvements in this area but it is still the case that |
| 159 |
% implementing a design specification in \LaTeX{} requires far more |
| 160 |
% \enquote{low-level} coding than is acceptable. |
| 161 |
% |
| 162 |
% \item[Programmer interface] |
| 163 |
% This language is the implementation language within which the |
| 164 |
% basic typesetting functionality is implemented, building upon the |
| 165 |
% primitives of \TeX{} (or a successor program). It may also be used |
| 166 |
% to implement the previous two languages \enquote{within} \TeX{}, as in |
| 167 |
% the |
| 168 |
% current \LaTeX{} system. |
| 169 |
% |
| 170 |
% \end{description} |
| 171 |
% |
| 172 |
% The last layer is covered by the conventions described in this |
| 173 |
% document, which describes a system aimed at providing a suitable |
| 174 |
% basis for coding \LaTeX3. Its main distinguishing features are |
| 175 |
% summarized here: |
| 176 |
% \begin{itemize} |
| 177 |
% \item A consistent naming scheme for all commands, including \TeX{} |
| 178 |
% primitives. |
| 179 |
% \item The classification of commands as \LaTeX{} functions or \LaTeX{} |
| 180 |
% parameters, and also their division into modules according to their |
| 181 |
% functionality. |
| 182 |
% \item A simple mechanism for controlling argument expansion. |
| 183 |
% \item Provision of a set of core \LaTeX{} functions that is sufficient |
| 184 |
% for handling programming constructs such as queues, sets, stacks, |
| 185 |
% property lists. |
| 186 |
% \item A \TeX{} programming environment in which, for example, all |
| 187 |
% white space is ignored. |
| 188 |
% \end{itemize} |
| 189 |
% |
| 190 |
% \section{The naming scheme} |
| 191 |
% |
| 192 |
% \LaTeX3 does not use |@| as a \enquote{letter} for defining |
| 193 |
% internal macros. Instead, the symbols |_| and |:| |
| 194 |
% are used in internal macro names to provide structure. In |
| 195 |
% contrast to the plain \TeX{} format and the \LaTeXe{} kernel, these |
| 196 |
% extra letters are used only between parts of a macro name (no |
| 197 |
% strange vowel replacement). |
| 198 |
% |
| 199 |
% While \TeX{} is actually a macro processor, by |
| 200 |
% convention for the \pkg{expl3} programming language we distinguish between |
| 201 |
% \emph{functions} and \emph{variables}. Functions can have arguments and they |
| 202 |
% are either expanded or executed. Variables can be assigned values and they |
| 203 |
% are used in arguments to functions; they are not used directly but are |
| 204 |
% manipulated by functions (including getting and setting functions). |
| 205 |
% Functions and variables with a related functionality (for example accessing |
| 206 |
% counters, or manipulating token lists, etc.)\ are collected together |
| 207 |
% into a |
| 208 |
% \emph{module}. |
| 209 |
% |
| 210 |
% \subsection{Examples} |
| 211 |
% |
| 212 |
% Before giving the details of the naming scheme, here are a few typical |
| 213 |
% examples to indicate the flavor of the scheme; first some variable |
| 214 |
% names. |
| 215 |
% \begin{quote} |
| 216 |
% \cs{l_tmpa_box} is a local variable (hence the~|l_| prefix) |
| 217 |
% corresponding to a box register.\\ |
| 218 |
% \cs{g_tmpa_int} is a global variable (hence the~|g_| prefix) |
| 219 |
% corresponding to an integer register (i.e., a \TeX{} count |
| 220 |
% register).\\ |
| 221 |
% \cs{c_empty_tl} is the constant~(|c_|) token list variable |
| 222 |
% that is always empty. |
| 223 |
% \end{quote} |
| 224 |
% |
| 225 |
% Now here is an example of a typical function name. |
| 226 |
% |
| 227 |
% \cs{seq_push:Nn} is the function which puts the token list specified |
| 228 |
% by its second argument onto the stack specified by its first argument. |
| 229 |
% The different natures of the two arguments are indicated by the~|:Nn| |
| 230 |
% suffix. The first argument must be a single token which \enquote{names} |
| 231 |
% the stack parameter: such single-token arguments are denoted~|N|. |
| 232 |
% The second argument is a normal \TeX{} \enquote{undelimited argument}, |
| 233 |
% which |
| 234 |
% may either be a single token or a balanced, brace-delimited token |
| 235 |
% list (which we shall here call a \textit{braced token list}): the~|n| |
| 236 |
% denotes such a \enquote{normal} argument form. The name of the function |
| 237 |
% indicates it belongs to the |seq| module. |
| 238 |
% |
| 239 |
% \subsection{Formal naming syntax} |
| 240 |
% |
| 241 |
% We shall now look in more detail at the syntax of these names. A |
| 242 |
% function name in \LaTeX3 has a name consisting of three parts: |
| 243 |
% \begin{quote} |
| 244 |
% |\|\meta{module}|_|\meta{description}|:|\meta{arg-spec} |
| 245 |
% \end{quote} |
| 246 |
% while a variable has (up to) four distinct parts to its name: |
| 247 |
% \begin{quote} |
| 248 |
% |\|\meta{scope}|_|\meta{module}|_|\meta{description}|_|\meta{type} |
| 249 |
% \end{quote} |
| 250 |
% |
| 251 |
% The syntax of all names contains |
| 252 |
% \begin{quote} |
| 253 |
% \meta{module} and \meta{description} |
| 254 |
% \end{quote} |
| 255 |
% and these two both give information about the command. |
| 256 |
% |
| 257 |
% A \emph{module} is a collection of closely related functions and |
| 258 |
% variables. Typical module names include~|int| for integer parameters |
| 259 |
% and related functions,~|seq| for sequences and~|box| for boxes. |
| 260 |
% |
| 261 |
% Packages providing new programming functionality will add new modules |
| 262 |
% as needed; the programmer can choose any unused name, consisting |
| 263 |
% of letters only, for a module. In general, the module name and module |
| 264 |
% prefix should be related: for example, the kernel module containing |
| 265 |
% \texttt{box} functions is called \texttt{l3box}. Module names and |
| 266 |
% programmers' contact details are listed in \pkg{l3prefixes.csv}. |
| 267 |
% |
| 268 |
% The \emph{description} gives more detailed information about the |
| 269 |
% function or parameter, and provides a unique name for it. It should |
| 270 |
% consist of letters and, possibly,~|_|~characters. In general, the |
| 271 |
% description should use |_| to divide up \enquote{words} or other easy to |
| 272 |
% follow parts of the name. For example, the \LaTeX3 kernel provides |
| 273 |
% \cs{if_cs_exist:N} which, as might be expected, tests if a command |
| 274 |
% name exists. |
| 275 |
% |
| 276 |
% Where functions for variable manipulation can perform assignments |
| 277 |
% either locally or globally, the latter case is indicated by the inclusion of |
| 278 |
% a |g| in the second part of the function name. Thus \cs{tl_set:Nn} is a local |
| 279 |
% function but \cs{tl_gset:Nn} acts globally. Functions of this type are |
| 280 |
% always documented together, and the scope of action may therefore be |
| 281 |
% inferred from the presence or absence of a |g|. See the next subsection for |
| 282 |
% more detail on variable scope. |
| 283 |
% |
| 284 |
% \subsubsection{Separating private and public material} |
| 285 |
% |
| 286 |
% One of the issues with the \TeX{} language is that it doesn't support |
| 287 |
% name spaces and encapsulation other than by convention. As a result |
| 288 |
% nearly every internal command in the \LaTeXe{} kernel has eventually |
| 289 |
% be used by extension packages as an entry point for modifications or |
| 290 |
% extensions. The consequences of this is that nowadays it is next to |
| 291 |
% impossible to change anything in the \LaTeXe{} kernel (even if it is |
| 292 |
% clearly just an internal command) without breaking something. |
| 293 |
% |
| 294 |
% In \pkg{expl3} we hope to improve this situation drastically by |
| 295 |
% clearly separating public interfaces (that extension packages can use |
| 296 |
% and rely on) and private functions and variables (that should not |
| 297 |
% appear outside of their module). There is (nearly) no way to enforce |
| 298 |
% this without severe computing overhead, so we implement it only |
| 299 |
% through a naming convention, and some support mechanisms. However, we |
| 300 |
% think that this naming convention is easy to understand and to follow, |
| 301 |
% so that we are confident that this will adopted and provides the |
| 302 |
% desired results. |
| 303 |
% |
| 304 |
% Functions created by a module may either be \enquote{public} (documented |
| 305 |
% with a defined interface) or \enquote{private} (to be used only within |
| 306 |
% that module, and thus not formally documented). It is important that |
| 307 |
% only documented interfaces are used; at the same time, it is necessary to |
| 308 |
% show within the name of a function or variable whether it is public |
| 309 |
% or private. |
| 310 |
% |
| 311 |
% To allow clear separation of these two cases, the following convention |
| 312 |
% is used. To denote a private function or a private variable (of the module), |
| 313 |
% two |_| characters are used in front of the module name, e.g. |
| 314 |
% \begin{verbatim} |
| 315 |
% \module_foo:nnn |
| 316 |
% \end{verbatim} |
| 317 |
% is a public function which should be documented while |
| 318 |
% \begin{verbatim} |
| 319 |
% \__module_foo:nnn |
| 320 |
% \end{verbatim} |
| 321 |
% is private to the module, and should \emph{not} be used outside of that |
| 322 |
% module. |
| 323 |
% |
| 324 |
% For variables, to avoid three |_| in a row, the separator for the variable |
| 325 |
% scope and any leading |_| for a private interface in the module part are |
| 326 |
% combined. Thus |
| 327 |
% \begin{verbatim} |
| 328 |
% \l_module_foo_tl |
| 329 |
% \end{verbatim} |
| 330 |
% is a public variable and |
| 331 |
% \begin{verbatim} |
| 332 |
% \l__module_foo_tl |
| 333 |
% \end{verbatim} |
| 334 |
% is private. |
| 335 |
% |
| 336 |
% \subsubsection{Using \texttt{@@} and \pkg{DocStrip} to mark private code} |
| 337 |
% |
| 338 |
% The formal syntax for internal functions allows clear separation of public |
| 339 |
% and private code, but includes redundant information (every internal function |
| 340 |
% or variable includes \texttt{__\meta{module}}). To aid programmers, the |
| 341 |
% \pkg{DocStrip} program introduces the syntax |
| 342 |
% \begin{quote} |
| 343 |
% \ttfamily |
| 344 |
% |%<@@=|\meta{module}|>| |
| 345 |
% \end{quote} |
| 346 |
% which then allows |@@| (and |_@@| in case of variables) to be used as |
| 347 |
% a place holder for \texttt{__\meta{module}} in code. Thus for example |
| 348 |
% \begin{verbatim} |
| 349 |
% %<@@=foo> |
| 350 |
% % \begin{macrocode} |
| 351 |
% \cs_new:Npn \@@_function:n #1 |
| 352 |
% ... |
| 353 |
% \tl_new:N \l_@@_my_tl |
| 354 |
% % \end{macrocode} |
| 355 |
% \end{verbatim} |
| 356 |
% is converted by \pkg{DocStrip} to |
| 357 |
% \begin{verbatim} |
| 358 |
% \cs_new:Npn \__foo_function:n #1 |
| 359 |
% ... |
| 360 |
% \tl_new:N \l__foo_my_tl |
| 361 |
% \end{verbatim} |
| 362 |
% on extraction. As you can see both |_@@| and |@@| are mapped to |
| 363 |
% \texttt{__\meta{module}}, because we think that this helps to |
| 364 |
% distinguish variables from functions in the source when the |@@| |
| 365 |
% convention is used. |
| 366 |
% |
| 367 |
% \subsubsection{Variables: declaration} |
| 368 |
% |
| 369 |
% In well-formed \pkg{expl3} code, variables should always be declared before |
| 370 |
% assignment is attempted. This is true even for variable types where the |
| 371 |
% underlying \TeX{} implementation will allow direct assignment. This applies |
| 372 |
% both to setting directly (\cs{tl_set:Nn}, etc.) and to setting equal |
| 373 |
% (\cs{tl_set_eq:NN}, etc.). |
| 374 |
% |
| 375 |
% To help programmers to adhere to this approach, the debugging option |
| 376 |
% |check-declarations| may be given |
| 377 |
% \begin{verbatim} |
| 378 |
% \debug_on:n { check-declarations } |
| 379 |
% \end{verbatim} |
| 380 |
% and will issue an error whenever an assignment is made to a non-declared |
| 381 |
% variable. There is a performance implication, so this option should only |
| 382 |
% be used for testing. |
| 383 |
% |
| 384 |
% \subsubsection{Variables: scope and type} |
| 385 |
% |
| 386 |
% The \meta{scope} part of the name describes how the variable can be |
| 387 |
% accessed. Variables are classified as local, global or constant. |
| 388 |
% This \emph{scope} type appears as a code at the beginning of the name; |
| 389 |
% the codes used are: |
| 390 |
% \begin{arg-description} |
| 391 |
% \item[c] constants (global variables whose value should not be |
| 392 |
% changed); |
| 393 |
% \item[g] variables whose value should only be set globally; |
| 394 |
% \item[l] variables whose value should only be set locally. |
| 395 |
% \end{arg-description} |
| 396 |
% |
| 397 |
% Separate functions are provided to assign data to local and global |
| 398 |
% variables; for example, \cs{tl_set:Nn} and \cs{tl_gset:Nn} respectively |
| 399 |
% set the value of a local or global \enquote{token list} variable. |
| 400 |
% Note that it is a poor \TeX{} practice to intermix local and global |
| 401 |
% assignments to a variable; otherwise you risk exhausting the save |
| 402 |
% stack.\footnote{See \emph{The \TeX{}book}, p.\,301, for further |
| 403 |
% information.} |
| 404 |
% |
| 405 |
% The \meta{type} is in the list of available |
| 406 |
% \emph{data-types};\footnote{Of course, if a totally new data type is |
| 407 |
% needed then this will not be the case. However, it is hoped that only |
| 408 |
% the kernel team will need to create new data types.} these include the |
| 409 |
% primitive \TeX{} data-types, such as the various registers, but to |
| 410 |
% these are added data-types built within the \LaTeX{} programming |
| 411 |
% system. |
| 412 |
% |
| 413 |
% The data types in \LaTeX3 are: |
| 414 |
% \begin{description} |
| 415 |
% \item[bitset] a string of bits (\texttt{0} and \texttt{1} tokens) that are |
| 416 |
% accessed by position or by name; |
| 417 |
% \item[bool] either true or false (the \LaTeX3 implementation does |
| 418 |
% not use \tn{iftrue} or \tn{iffalse}); |
| 419 |
% \item[box] box register; |
| 420 |
% \item[cctab] category code table; |
| 421 |
% \item[clist] comma separated list; |
| 422 |
% \item[coffin] a \enquote{box with handles} --- a higher-level data |
| 423 |
% type for carrying out |box| alignment operations; |
| 424 |
% \item[dim] \enquote{rigid} lengths; |
| 425 |
% \item[fp] floating-point values; |
| 426 |
% \item[fparray] fixed-size vector of floating-point values; |
| 427 |
% \item[int] integer-valued count register; |
| 428 |
% \item[intarray] fixed-size vector of integer values; |
| 429 |
% \item[ior] an input stream (for reading from a file); |
| 430 |
% \item[iow] an output stream (for writing to a file); |
| 431 |
% \item[muskip] math mode \enquote{rubber} lengths; |
| 432 |
% \item[prop] property list; |
| 433 |
% \item[regex] regular expression; |
| 434 |
% \item[seq] sequence: a data-type used to implement lists (with |
| 435 |
% access at both ends) and stacks; |
| 436 |
% \item[skip] \enquote{rubber} lengths; |
| 437 |
% \item[str] \TeX{} strings: a special case of |tl| in which all |
| 438 |
% characters have category \enquote{other} (catcode~$12$), |
| 439 |
% other than spaces which are category \enquote{space} |
| 440 |
% (catcode~$10$); |
| 441 |
% \item[token] equal to a single arbitrary token; |
| 442 |
% \item[tl] \enquote{token list variables}: placeholders for token lists. |
| 443 |
% \end{description} |
| 444 |
% When the \meta{type} and \meta{module} are identical (as often happens in |
| 445 |
% the more basic modules) the \meta{module} part is often omitted for |
| 446 |
% aesthetic reasons. |
| 447 |
% |
| 448 |
% The name \enquote{token list} may cause confusion, and so some |
| 449 |
% background is useful. \TeX{} works with tokens and lists of tokens, |
| 450 |
% rather than characters. It provides two ways to store these token |
| 451 |
% lists: within macros and as token registers (|toks|). The |
| 452 |
% implementation in \LaTeX3 means that |toks| are not required, and that |
| 453 |
% all operations for storing tokens can use the |tl| variable type. |
| 454 |
% |
| 455 |
% There are two more special types of constants: |
| 456 |
% \begin{arg-description} |
| 457 |
% \item[q] constants of quark type; |
| 458 |
% \item[s] constants of scan mark type. |
| 459 |
% \end{arg-description} |
| 460 |
% The \meta{type} part of quark and scan mark constants is omitted, and |
| 461 |
% the \meta{module} part of general quarks and scan marks is often |
| 462 |
% omitted too. |
| 463 |
% |
| 464 |
% Experienced \TeX{} programmers will notice that some of the variable |
| 465 |
% types listed are native \TeX{} registers whilst others are not. In |
| 466 |
% general, the underlying \TeX{} implementation for a data structure may |
| 467 |
% vary but the \emph{documented interface} will be stable. For example, |
| 468 |
% the |prop| data type was originally implemented as a |toks|, but |
| 469 |
% is currently built on top of the |tl| data structure. |
| 470 |
% |
| 471 |
% \subsubsection{Variables: guidance} |
| 472 |
% |
| 473 |
% Both comma lists and sequences have similar characteristics. |
| 474 |
% They both use special delimiters to mark out one entry from the |
| 475 |
% next, and are both accessible at both ends. In general, it is |
| 476 |
% easier to create comma lists `by hand' as they can be typed |
| 477 |
% in directly. User input often takes the form of a comma separated |
| 478 |
% list and so there are many cases where this is the obvious |
| 479 |
% data type to use. On the other hand, sequences use special internal |
| 480 |
% tokens to separate entries. This means that they can be used to |
| 481 |
% contain material that comma lists cannot (such as items that may |
| 482 |
% themselves contain commas!). In general, comma lists should be |
| 483 |
% preferred for creating fixed lists inside programs and for |
| 484 |
% handling user input where commas will not occur. On the other |
| 485 |
% hand, sequences should be used to store arbitrary lists of |
| 486 |
% data. |
| 487 |
% |
| 488 |
% \pkg{expl3} implements stacks using the sequence data structure. |
| 489 |
% Thus creating stacks involves first creating a sequence, and |
| 490 |
% then using the sequence functions which work in a stack manner |
| 491 |
% (\cs{seq_push:Nn}, \emph{etc}.). |
| 492 |
% |
| 493 |
% Due to the nature of the underlying \TeX{} implementation, it is |
| 494 |
% possible to assign values to token list variables and comma lists |
| 495 |
% without first declaring them. However, this is \emph{not supported |
| 496 |
% behavior}. The \LaTeX3 coding convention is that all variables must |
| 497 |
% be declared before use. |
| 498 |
% |
| 499 |
% The \pkg{expl3} package can be loaded with the \texttt{check-declarations} |
| 500 |
% option to verify that all variables are declared before use. This has |
| 501 |
% a performance implication and is therefore intended for testing during |
| 502 |
% development and not for use in production documents. |
| 503 |
% |
| 504 |
% \subsubsection{Functions: argument specifications} |
| 505 |
% |
| 506 |
% Function names end with an \meta{arg-spec} after a colon. This |
| 507 |
% gives an indication of the types of argument that a function takes, |
| 508 |
% and provides a convenient method of naming similar functions that |
| 509 |
% differ only in their argument forms (see the next section for |
| 510 |
% examples). |
| 511 |
% |
| 512 |
% The \meta{arg-spec} consists of a (possibly empty) list of letters, |
| 513 |
% each denoting one argument of the function. The letter, including |
| 514 |
% its case, conveys information about the type of argument required. |
| 515 |
% |
| 516 |
% All functions have a base form with arguments using one of the |
| 517 |
% following argument specifiers: |
| 518 |
% \begin{arg-description} |
| 519 |
% \item[n] Unexpanded token or braced token list.\\ |
| 520 |
% This is a standard \TeX{} undelimited macro argument. |
| 521 |
% \item[N] Single token (unlike~|n|, the argument must \emph{not} be |
| 522 |
% surrounded by braces).\\ |
| 523 |
% A typical example of a command taking an~|N| |
| 524 |
% argument is~|\cs_set|, in which the command being defined must be |
| 525 |
% unbraced. |
| 526 |
% \item[p] Primitive \TeX{} parameter specification.\\ |
| 527 |
% This can be something simple like~|#1#2#3|, but may use arbitrary |
| 528 |
% delimited argument syntax such as: |#1,#2\q_stop#3|. This is used |
| 529 |
% when defining functions. |
| 530 |
% \item[T,F] |
| 531 |
% These are special cases of~|n| arguments, used for the |
| 532 |
% true and false code in conditional commands. |
| 533 |
% \end{arg-description} |
| 534 |
% There are two other specifiers with more general meanings: |
| 535 |
% \begin{arg-description} |
| 536 |
% \item[D] Stands for \textbf{Do not use}. This special case is used |
| 537 |
% for \TeX{} primitives. These functions have no standardized |
| 538 |
% syntax, they are engine dependent and their name can change |
| 539 |
% without warning, thus their use is \emph{strongly discouraged} in |
| 540 |
% package code: programmers should instead use the interfaces |
| 541 |
% documented in \href{interface3.pdf}{interface3.pdf}%^^A |
| 542 |
% \footnote{If a primitive offers a functionality not yet in the |
| 543 |
% kernel, programmers and users are encouraged to write to the |
| 544 |
% team describing |
| 545 |
% their use-case and intended behavior, so that a possible |
| 546 |
% interface can be discussed. Temporarily, while an interface is |
| 547 |
% not provided, programmers may use the procedure described in the |
| 548 |
% \href{l3styleguide.pdf}{l3styleguide.pdf}.}. |
| 549 |
% \item[w] This means that the argument syntax is \enquote{weird} in that it |
| 550 |
% does not follow any standard rule. It is used for functions with |
| 551 |
% arguments that take non standard forms: examples are \TeX{}-level |
| 552 |
% delimited arguments and the boolean tests needed after certain |
| 553 |
% primitive |\if|\ldots{} commands. |
| 554 |
% \end{arg-description} |
| 555 |
% |
| 556 |
% In case of |n| arguments that consist of a single token the |
| 557 |
% surrounding braces can be omitted in nearly all |
| 558 |
% situations---functions that force the use of braces even for single |
| 559 |
% token arguments are explicitly mentioned. However, programmers are |
| 560 |
% encouraged to always use braces around \texttt{n} arguments, as this |
| 561 |
% makes the relationship between function and argument clearer. |
| 562 |
% |
| 563 |
% Further argument specifiers are available as part of the expansion |
| 564 |
% control system. These are discussed in the next section. |
| 565 |
% |
| 566 |
% \section{Expansion control} |
| 567 |
% |
| 568 |
% Let's take a look at some typical operations one might want to |
| 569 |
% perform. Suppose we maintain a stack of open files and we use the |
| 570 |
% stack |\g_ior_file_name_seq| to keep track of them (\texttt{ior} is |
| 571 |
% the prefix used for the file reading module). The basic operation here |
| 572 |
% is to push a name onto this stack which could be done by the operation |
| 573 |
% \begin{quote} |
| 574 |
% \cs{seq_gpush:Nn} |\g_ior_file_name_seq {#1}| |
| 575 |
% \end{quote} |
| 576 |
% where |#1| is the filename. In other words, this operation would |
| 577 |
% push the file name as is onto the stack. |
| 578 |
% |
| 579 |
% However, we might face a situation where the filename is stored in |
| 580 |
% a variable of some sort, say |\l_ior_curr_file_tl|. In this case we |
| 581 |
% want to retrieve the value of the variable. If we simply use |
| 582 |
% \begin{quote} |
| 583 |
% \cs{seq_gpush:Nn} |\g_ior_file_name_seq| |\l_ior_curr_file_tl| |
| 584 |
% \end{quote} |
| 585 |
% we do not get the value of the variable pushed onto the stack, |
| 586 |
% only the variable name itself. Instead a suitable number of |
| 587 |
% \cs{exp_after:wN} would be necessary (together with extra braces) to |
| 588 |
% change the order of expansion,\footnote{\cs{exp_after:wN} is |
| 589 |
% the \LaTeX3 name for the \TeX{} \tn{expandafter} primitive.} i.e. |
| 590 |
% \begin{quote} |
| 591 |
% \cs{exp_after:wN} \\ |
| 592 |
% | |\cs{seq_gpush:Nn} \\ |
| 593 |
% \cs{exp_after:wN} \\ |
| 594 |
% | \g_ior_file_name_seq| \\ |
| 595 |
% \cs{exp_after:wN} \\ |
| 596 |
% | { \l_ior_curr_file_tl }| |
| 597 |
% \end{quote} |
| 598 |
% |
| 599 |
% The above example is probably the simplest case but already shows |
| 600 |
% how the code changes to something difficult to understand. |
| 601 |
% Furthermore there is an assumption in this: that the storage bin |
| 602 |
% reveals its contents after exactly one expansion. Relying on this |
| 603 |
% means that you cannot do proper checking plus you have to know |
| 604 |
% exactly how a storage bin acts in order to get the correct number |
| 605 |
% of expansions. Therefore \LaTeX3 provides the programmer with a |
| 606 |
% general scheme that keeps the code compact and easy to understand. |
| 607 |
% |
| 608 |
% To denote that some argument to a function needs special treatment one |
| 609 |
% just uses different letters in the arg-spec part of the function to |
| 610 |
% mark the desired behavior. In the above example one would write |
| 611 |
% \begin{quote} |
| 612 |
% \cs{seq_gpush:NV} |\g_ior_file_name_seq \l_ior_curr_file_tl| |
| 613 |
% \end{quote} |
| 614 |
% to achieve the desired effect. Here the |V| (the second argument) |
| 615 |
% is for \enquote{retrieve the value of the variable} before passing it to |
| 616 |
% the base function. |
| 617 |
% |
| 618 |
% The following letters can be used to denote special treatment of |
| 619 |
% arguments before passing it to the base function: |
| 620 |
% \begin{description} |
| 621 |
% \item[c] Character string used as a command name.\\ The argument (a |
| 622 |
% token or braced token list) is \emph{fully expanded}; the result |
| 623 |
% must be a sequence of characters which is then used to construct a |
| 624 |
% command name (\emph{via}~\tn{csname} \ldots \tn{endcsname}). This |
| 625 |
% command name is a single token that is passed to the function as |
| 626 |
% the argument. Hence |
| 627 |
% \begin{quote} |
| 628 |
% \cs{seq_gpush:cV} |{ g_file_name_seq }| \cs{l_tmpa_tl} |
| 629 |
% \end{quote} |
| 630 |
% is equivalent to |
| 631 |
% \begin{quote} |
| 632 |
% \cs{seq_gpush:NV} |\g_file_name_seq| \cs{l_tmpa_tl}. |
| 633 |
% \end{quote} |
| 634 |
% Full expansion means that (a) the entire |
| 635 |
% argument must be expandable and (b) any variables are |
| 636 |
% converted to their content. So the preceding examples are also |
| 637 |
% equivalent to |
| 638 |
% \begin{quote} |
| 639 |
% \cs{tl_new:N} |\g_file_seq_name_tl| \\ |
| 640 |
% \cs{tl_gset:Nn} |\g_file_seq_name_tl { g_file_name_seq }| \\ |
| 641 |
% \cs{seq_gpush:cV} |{| \cs{tl_use:N} |\g_file_seq_name_tl }| \cs{l_tmpa_tl}. |
| 642 |
% \end{quote} |
| 643 |
% (Token list variables are expandable and we could omit the |
| 644 |
% accessor function \cs{tl_use:N}. Other variable types require the |
| 645 |
% appropriate \cs{\meta{type}_use:N} functions to be used in this |
| 646 |
% context.) |
| 647 |
% \item[V] Value of a variable.\\ |
| 648 |
% This means that the contents of the variable in question is used |
| 649 |
% as the argument, be it an integer, a length-type register, a token |
| 650 |
% list variable or similar. The value is passed to the function as a |
| 651 |
% braced token list. Can be applied to variables which have a |
| 652 |
% \cs{\meta{type}_use:N} function (other than boxes and floating points). |
| 653 |
% \item[v] Value of a variable, constructed from a character string |
| 654 |
% used as a command name.\\ |
| 655 |
% This is a combination of |c| and |V| which first constructs a |
| 656 |
% control sequence from the argument and then passes the value of |
| 657 |
% the resulting variable to the function. Can be applied to |
| 658 |
% variables which have a \cs{\meta{type}_use:N} function (other than |
| 659 |
% boxes and floating points). |
| 660 |
% \item[e] Fully-expanded token or braced token list.\\ |
| 661 |
% This means that the argument is expanded as in the replacement |
| 662 |
% text of a~\tn{message}, and the expansion is passed to the function as |
| 663 |
% a braced token list. |
| 664 |
% \item[o] One-level-expanded token or braced token list.\\ |
| 665 |
% This means that the argument is expanded one level, as by |
| 666 |
% \tn{expandafter}, and the expansion is passed to the function as a |
| 667 |
% braced token list. Note that if the original argument is a braced |
| 668 |
% token list then only the first token in that list is expanded. |
| 669 |
% In general, using \texttt{V} should be preferred to using |
| 670 |
% \texttt{o} for simple variable retrieval. |
| 671 |
% \item[f] Expanding the first token recursively in a braced token |
| 672 |
% list.\\ Almost the same as the |e| type except here the token list |
| 673 |
% is expanded fully until the first unexpandable token is found and |
| 674 |
% the rest is left unchanged. Note that if this function finds a |
| 675 |
% space at the beginning of the argument it gobbles it and does not |
| 676 |
% expand the next token. |
| 677 |
% \item[x] Fully-expanded token or braced token list.\\ |
| 678 |
% This expansion is very similar to |e|-type but is not nestable, |
| 679 |
% can only be used to create non-expandable functions, and requires |
| 680 |
% that |#| tokens are doubled in the argument. In almost all cases, |
| 681 |
% |e|-type should be preferred: retained largely for historical |
| 682 |
% reasons, and should where possible be replaced by the |e|-type |
| 683 |
% equivalent. |
| 684 |
% \end{description} |
| 685 |
% |
| 686 |
% \subsection{Simpler means better} |
| 687 |
% |
| 688 |
% Anyone who programs in \TeX{} is frustratingly familiar with the |
| 689 |
% problem of arranging that arguments to functions are suitably expanded |
| 690 |
% before the function is called. To illustrate how expansion control |
| 691 |
% can bring instant relief to this problem we shall consider two |
| 692 |
% examples copied from \texttt{latex.ltx}. |
| 693 |
% |
| 694 |
% \begin{verbatim} |
| 695 |
% \global\expandafter\let |
| 696 |
% \csname\cf@encoding \string#1\expandafter\endcsname |
| 697 |
% \csname ?\string#1\endcsname |
| 698 |
% \end{verbatim} |
| 699 |
% This first piece of code is in essence simply a global \tn{let} whose |
| 700 |
% two arguments firstly have to be constructed before \tn{let} is |
| 701 |
% executed. The |#1| is a control sequence name such as |
| 702 |
% |\textcurrency|. The token to be defined is obtained by |
| 703 |
% concatenating the characters of the current font encoding stored in |
| 704 |
% |\cf@encoding|, which has to be fully expanded, and the name of the |
| 705 |
% symbol. The second token is the same except it uses the default |
| 706 |
% encoding |?|. The result is a mess of interwoven \tn{expandafter} |
| 707 |
% and \tn{csname} beloved of all \TeX{} programmers, and the code is |
| 708 |
% essentially unreadable. |
| 709 |
% |
| 710 |
% Using the conventions and functionality outlined here, the task would |
| 711 |
% be achieved with code such as this: |
| 712 |
% \begin{verbatim} |
| 713 |
% \cs_gset_eq:cc |
| 714 |
% { \cf@encoding \token_to_str:N #1 } { ? \token_to_str:N #1 } |
| 715 |
% \end{verbatim} |
| 716 |
% The command \cs{cs_gset_eq:cc} is a global~\tn{let} that generates |
| 717 |
% command names out of both of its arguments before making the |
| 718 |
% definition. This produces code that is far more readable and more |
| 719 |
% likely to be correct first time. (\cs{token_to_str:N} is the \LaTeX3 |
| 720 |
% name for \tn{string}.) |
| 721 |
% |
| 722 |
% Here is the second example. |
| 723 |
% \begin{verbatim} |
| 724 |
% \expandafter |
| 725 |
% \in@ |
| 726 |
% \csname sym#3% |
| 727 |
% \expandafter |
| 728 |
% \endcsname |
| 729 |
% \expandafter |
| 730 |
% {% |
| 731 |
% \group@list}% |
| 732 |
% \end{verbatim} |
| 733 |
% This piece of code is part of the definition of another function. It |
| 734 |
% first produces two things: a token list, by expanding |\group@list| once; |
| 735 |
% and a token whose name comes from~`|sym#3|'. Then the function~\cs{in@} |
| 736 |
% is called and this tests if its first argument occurs in the token list |
| 737 |
% of its second argument. |
| 738 |
% |
| 739 |
% Again we can improve enormously on the code. First we shall rename |
| 740 |
% the function~\cs{in@}, which tests if its first argument appears |
| 741 |
% within its second argument, according to our conventions. Such a |
| 742 |
% function takes two normal \enquote{\texttt{n}} arguments and operates |
| 743 |
% on token lists: it might reasonably be named |\tl_test_in:nn|. Thus |
| 744 |
% the variant function we need would be defined with the appropriate |
| 745 |
% argument types and its name would be |\tl_test_in:cV|. Now this code |
| 746 |
% fragment would be simply: |
| 747 |
% \begin{verbatim} |
| 748 |
% \tl_test_in:cV { sym #3 } \group@list |
| 749 |
% \end{verbatim} |
| 750 |
% This code could be improved further by using a sequence |\l_group_seq| |
| 751 |
% rather than the bare token list |\group@list|. Note that, in addition |
| 752 |
% to the lack of \tn{expandafter}, the space after the~|}| is |
| 753 |
% silently ignored since all white space is ignored in this programming |
| 754 |
% environment. |
| 755 |
% |
| 756 |
% \subsection{New functions from old} |
| 757 |
% |
| 758 |
% For many common functions the \LaTeX3 kernel provides variants |
| 759 |
% with a range of argument forms, and similarly it is expected that |
| 760 |
% extension packages providing new functions will make them available in |
| 761 |
% all the commonly needed forms. |
| 762 |
% |
| 763 |
% However, there will be occasions where it is necessary to construct a |
| 764 |
% new such variant form; therefore the expansion module provides a |
| 765 |
% straightforward mechanism for the creation of functions with any |
| 766 |
% required argument type, starting from a function that takes \enquote{normal} |
| 767 |
% \TeX{} undelimited arguments. |
| 768 |
% |
| 769 |
% To illustrate this let us suppose you have a \enquote{base function} |
| 770 |
% |\demo_cmd:Nnn| that takes three normal arguments, and that you need |
| 771 |
% to construct the variant |\demo_cmd:cne|, for which the first argument |
| 772 |
% is used to construct the \emph{name} of a command, whilst the third |
| 773 |
% argument must be fully expanded before being passed to |
| 774 |
% |\demo_cmd:Nnn|. |
| 775 |
% To produce the variant form from the base form, simply use this: |
| 776 |
% \begin{verbatim} |
| 777 |
% \cs_generate_variant:Nn \demo_cmd:Nnn { cne } |
| 778 |
% \end{verbatim} |
| 779 |
% This defines the variant form so that you can then write, for example: |
| 780 |
% \begin{verbatim} |
| 781 |
% \demo_cmd:cne { abc } { pq } { \rst \xyz } |
| 782 |
% \end{verbatim} |
| 783 |
% rather than \ldots\ well, something like this! |
| 784 |
% \begin{verbatim} |
| 785 |
% \def \tempa {{pq}}% |
| 786 |
% \edef \tempb {\rst \xyz}% |
| 787 |
% \expandafter |
| 788 |
% \demo@cmd:nnn |
| 789 |
% \csname abc% |
| 790 |
% \expandafter |
| 791 |
% \expandafter |
| 792 |
% \expandafter |
| 793 |
% \endcsname |
| 794 |
% \expandafter |
| 795 |
% \tempa |
| 796 |
% \expandafter |
| 797 |
% {% |
| 798 |
% \tempb |
| 799 |
% }% |
| 800 |
% \end{verbatim} |
| 801 |
% |
| 802 |
% Another example: you may wish to declare a function |
| 803 |
% |\demo_cmd_b:enene|, a variant of an existing function |
| 804 |
% |\demo_cmd_b:nnnnn|, that fully |
| 805 |
% expands arguments 1,~3 and~5, and produces commands to pass as |
| 806 |
% arguments 2 and~4 using~\tn{csname}. |
| 807 |
% The definition you need is simply |
| 808 |
% \begin{verbatim} |
| 809 |
% \cs_generate_variant:Nn \demo_cmd_b:nnnnn { enene } |
| 810 |
% \end{verbatim} |
| 811 |
% |
| 812 |
% This extension mechanism is written so that if the same new form of |
| 813 |
% some existing command is implemented by two extension packages then the |
| 814 |
% two definitions are identical and thus no conflict occurs. |
| 815 |
% |
| 816 |
% \section{The distribution} |
| 817 |
% |
| 818 |
% The \pkg{expl3} modules are designed to be loaded on top of \LaTeXe{}. |
| 819 |
% |
| 820 |
% \begin{bfseries} |
| 821 |
% The core \pkg{expl3} language is broadly stable, and thus |
| 822 |
% the syntax conventions and functions provided |
| 823 |
% are now ready for wider use. There may still be changes to some |
| 824 |
% functions, but these will be minor when compared to the scope of |
| 825 |
% \pkg{expl3}. A robust mechanism is in place for such deprecations. |
| 826 |
% \end{bfseries} |
| 827 |
% |
| 828 |
% The distribution of \pkg{expl3} is split up into three packages on |
| 829 |
% CTAN: \pkg{l3kernel}, \pkg{l3packages} and \pkg{l3experimental}. |
| 830 |
% The core programming layer provided by \pkg{l3kernel} has been loaded |
| 831 |
% as part of the \LaTeX{} since 2020-02-02. For historical reasons, in |
| 832 |
% older kernel releases |
| 833 |
% \begin{verbatim} |
| 834 |
% \RequirePackage{expl3} |
| 835 |
% \end{verbatim} |
| 836 |
% loads the code distributed as \pkg{l3kernel}. This monolithic |
| 837 |
% package contains all of the modules regarded by the team as stable, |
| 838 |
% and any changes in this code are very limited. This material is |
| 839 |
% therefore suitable for use in third-party packages without concern |
| 840 |
% about changes in support. All of this code is documented in |
| 841 |
% \texttt{interface3.pdf}. |
| 842 |
% |
| 843 |
% The material in \pkg{l3packages} is also stable; this bundle provides |
| 844 |
% user-level commands, some of which have been integrated in the |
| 845 |
% \LaTeX{} kernel. |
| 846 |
% |
| 847 |
% Finally, \pkg{l3experimental} contains modules ready for public use |
| 848 |
% but not yet integrated into \pkg{l3kernel}. These modules have to |
| 849 |
% be loaded explicitly. The team anticipate that all of these modules |
| 850 |
% will move to stable status over time, but they may be more flexible |
| 851 |
% in terms of interface and functionality detail. Feedback on these |
| 852 |
% modules is extremely valuable. |
| 853 |
% |
| 854 |
% \section{Moving from \LaTeXe{} to \pkg{expl3}} |
| 855 |
% |
| 856 |
% To help programmers to use \pkg{expl3} code in existing \LaTeXe{} package, |
| 857 |
% some short notes on making the change are probably desirable. |
| 858 |
% Suggestions for inclusion here are welcome! Some of the following |
| 859 |
% is concerned with code, and some with coding style. |
| 860 |
% |
| 861 |
% \begin{itemize} |
| 862 |
% \item \pkg{expl3} is mainly focused on programming. This means that |
| 863 |
% some areas still require the use of \LaTeXe{} internal macros. |
| 864 |
% For example, you may well need \tn{IfPackageLoadedTF}, as there |
| 865 |
% is currently no native \pkg{expl3} package loading module. |
| 866 |
% \item User level macros should be generated using the mechanism |
| 867 |
% available in the \pkg{ltcmd} module, which is part of the |
| 868 |
% the \LaTeX{} kernel since 2020-10-01. |
| 869 |
% \item At an internal level, most functions should be generated |
| 870 |
% \tn{long} (using \cs{cs_new:Npn}) rather than \enquote{short} (using |
| 871 |
% \cs{cs_new_nopar:Npn}). |
| 872 |
% \item Where possible, declare all variables and functions (using |
| 873 |
% \cs{cs_new:Npn}, \cs{tl_new:N}, etc.) before use. |
| 874 |
% \item Prefer \enquote{higher-level} functions over \enquote{lower-level}, |
| 875 |
% where possible. So for example use \cs{cs_if_exist:NTF} and not |
| 876 |
% \cs{if_cs_exist:N}. |
| 877 |
% \item Use space to make code readable. In general, we recommend |
| 878 |
% a layout such as: |
| 879 |
% \begin{verbatim} |
| 880 |
% \cs_new:Npn \foo_bar:Nn #1#2 |
| 881 |
% { |
| 882 |
% \cs_if_exist:NTF #1 |
| 883 |
% { \__foo_bar:n {#2} } |
| 884 |
% { \__foo_bar:nn {#2} { literal } } |
| 885 |
% } |
| 886 |
% \end{verbatim} |
| 887 |
% where spaces are used around |{| and |}| except for isolated |
| 888 |
% |#1|, |#2|, etc. |
| 889 |
% \item Put different code items on separate lines: readability is |
| 890 |
% much more useful than compactness. |
| 891 |
% \item Use long, descriptive names for functions and variables, |
| 892 |
% and for auxiliary functions use the parent function name plus |
| 893 |
% |aux|, |auxi|, |auxii| and so on. |
| 894 |
% \item If in doubt, ask the team: someone will soon get back to you! |
| 895 |
% \end{itemize} |
| 896 |
% |
| 897 |
% \section{Load-time options for \pkg{expl3}} |
| 898 |
% |
| 899 |
% To support code authors, the \pkg{expl3} package for \LaTeXe{} includes |
| 900 |
% a small number of load-time options. These all work in a key--value |
| 901 |
% sense, recognizing the \texttt{true} and \texttt{false} values. Giving |
| 902 |
% the option name alone is equivalent to using the option with the |
| 903 |
% \texttt{true} value. |
| 904 |
% |
| 905 |
% \DescribeOption{check-declarations} |
| 906 |
% All variables used in \pkg{expl3} code should be declared. This is enforced |
| 907 |
% by \TeX{} for variable types based on \TeX{} registers, but not for those |
| 908 |
% which are constructed using macros as the underlying storage system. The |
| 909 |
% \texttt{check-declarations} option enables checking for all variable |
| 910 |
% assignments, issuing an error if any variables are assigned without being |
| 911 |
% initialized. See also \cs{debug_on:n} \texttt{\{check-declarations\}} |
| 912 |
% in \pkg{interface3} for finer control. |
| 913 |
% |
| 914 |
% \DescribeOption{log-functions} |
| 915 |
% The \texttt{log-functions} option is used to enable recording of every new |
| 916 |
% function name in the \texttt{.log} file. This is useful for debugging |
| 917 |
% purposes, as it means that there is a complete list of all functions |
| 918 |
% created by each module loaded (with the exceptions of a very small number |
| 919 |
% required by the bootstrap code). See also \cs{debug_on:n} |
| 920 |
% \texttt{\{log-functions\}} in \pkg{interface3} for finer control. |
| 921 |
% |
| 922 |
% \DescribeOption{backend} |
| 923 |
% Selects the backend to be used for color, graphics and related operations that |
| 924 |
% are backend-dependent. Options available are |
| 925 |
% \begin{itemize}[font = \texttt] |
| 926 |
% \item[dvips] Use the \texttt{dvips} driver. |
| 927 |
% \item[dvipdfmx] Use the \texttt{dvipdfmx} driver. |
| 928 |
% \item[dvisvgm] Use the \texttt{dvisvgm} driver. |
| 929 |
% \item[luatex] Use the direct PDF output mode of \LuaTeX{} |
| 930 |
% \item[pdftex] Use the direct PDF output mode of \pdfTeX{} |
| 931 |
% \item[xetex] Use the \XeTeX{} version of the \texttt{dvipdfmx} driver. |
| 932 |
% \end{itemize} |
| 933 |
% For historical reasons, there is also \texttt{pdfmode} as an equivalent of |
| 934 |
% \texttt{luatex} or \texttt{pdftex}, and \texttt{xdvipdfmx} as |
| 935 |
% an equivalent to \texttt{xetex}, but these are deprecated |
| 936 |
% |
| 937 |
% \DescribeOption{suppress-backend-headers} |
| 938 |
% The \texttt{suppress-backend-headers} option suppresses loading of |
| 939 |
% backend-specific header files; currently this only affects \texttt{dvips}. |
| 940 |
% This option is available to support DVI-based routes that do not |
| 941 |
% support the |header| line used by \texttt{dvips}. |
| 942 |
% |
| 943 |
% The debugging options may also be given using |
| 944 |
% \verb|\keys_set:nn { sys } { ... }|; the \texttt{backend} option can be |
| 945 |
% given in this way \emph{only} if a backend has not already been loaded. |
| 946 |
% This method of setting options is useful where \pkg{expl3} is pre-loaded |
| 947 |
% by the \LaTeXe{} format. |
| 948 |
% |
| 949 |
% \section{Using \pkg{expl3} with formats other than \LaTeXe{}} |
| 950 |
% |
| 951 |
% As well as the \LaTeXe{} package \pkg{expl3}, there is also a |
| 952 |
% \enquote{generic} loader for the code, \texttt{expl3-generic.tex}. |
| 953 |
% This may be loaded using the plain \TeX{} syntax |
| 954 |
% \begin{verbatim} |
| 955 |
% \input expl3-generic % |
| 956 |
% \end{verbatim} |
| 957 |
% This enables the programming layer to work with the other formats. |
| 958 |
% As no options are available loading in this way, the \enquote{native} |
| 959 |
% drivers are automatically used. If this \enquote{generic} loader is |
| 960 |
% used with \LaTeXe{} the code automatically switches to the appropriate |
| 961 |
% package route. |
| 962 |
% |
| 963 |
% After loading the programming layer using the generic interface, the |
| 964 |
% commands \cs{ExplSyntaxOn} and \cs{ExplSyntaxOff} and the code-level |
| 965 |
% functions and variables detailed in \pkg{interface3} are available. |
| 966 |
% Note that other \LaTeXe{} packages \emph{using} \pkg{expl3} are not |
| 967 |
% loadable: package loading is dependent on the \LaTeXe{} package-management |
| 968 |
% mechanism. |
| 969 |
% |
| 970 |
% \section{Getting the version of \pkg{expl3}} |
| 971 |
% |
| 972 |
% \begin{function}{\ExplLoaderFileDate} |
| 973 |
% Once the programming layer is loaded by one of the loaders, you can access |
| 974 |
% its version in the ISO date format \meta{year}-\meta{month}-\meta{day}, |
| 975 |
% through \cs{ExplLoaderFileDate}. |
| 976 |
% |
| 977 |
% The current version of \pkg{expl3} is \ExplLoaderFileDate. |
| 978 |
% \end{function} |
| 979 |
% |
| 980 |
% \section{Engine/primitive requirements} |
| 981 |
% |
| 982 |
% To use \pkg{expl3} and the higher level packages provided by the |
| 983 |
% team, the minimal set of primitive requirements is currently described |
| 984 |
% in \href{README.md}{README.md}. |
| 985 |
% |
| 986 |
% Practically, these requirements are met by the engines |
| 987 |
% \begin{itemize} |
| 988 |
% \item \pdfTeX{} v1.40.20 or later. |
| 989 |
% \item \XeTeX{} v0.999991 or later. |
| 990 |
% \item \LuaTeX{} v1.10 or later. |
| 991 |
% \item e-(u)\pTeX{} v3.8.2 or later. |
| 992 |
% \item Prote (2021) or later. |
| 993 |
% \end{itemize} |
| 994 |
% |
| 995 |
% Additional modules beyond the core of \pkg{expl3} may require additional |
| 996 |
% primitives. In particular, third-party authors may significantly |
| 997 |
% extend the primitive coverage requirements. |
| 998 |
% |
| 999 |
% \section{The \LaTeX{} Project} |
| 1000 |
% |
| 1001 |
% Development of \LaTeX3 is carried out by The \LaTeX{} Project: |
| 1002 |
% \url{https://www.latex-project.org/latex3/}. |
| 1003 |
% |
| 1004 |
% \begin{thebibliography}{1} |
| 1005 |
% |
| 1006 |
% \bibitem{A-W:K-TB} |
| 1007 |
% Donald E Knuth |
| 1008 |
% \newblock \emph{The \TeX{}book}. |
| 1009 |
% \newblock Addison-Wesley, Reading, Massachusetts, 1984. |
| 1010 |
% |
| 1011 |
% \bibitem{A-W:GMS94} |
| 1012 |
% Goossens, Mittelbach and Samarin. |
| 1013 |
% \newblock \emph{ The \LaTeX{} Companion}. |
| 1014 |
% \newblock Addison-Wesley, Reading, Massachusetts, 1994. |
| 1015 |
% |
| 1016 |
% \bibitem{A-W:LLa94} |
| 1017 |
% Leslie Lamport. |
| 1018 |
% \newblock \emph{\LaTeX{}: A Document Preparation System}. |
| 1019 |
% \newblock Addison-Wesley, Reading, Massachusetts, second edition, 1994. |
| 1020 |
% |
| 1021 |
% \bibitem{tub:MR97-1} |
| 1022 |
% Frank Mittelbach and Chris Rowley. |
| 1023 |
% \newblock \enquote{The \LaTeX{} Project}. |
| 1024 |
% \newblock \emph{TUGboat}, |
| 1025 |
% Vol.\,18, No.\,3, pp.\,195--198, 1997. |
| 1026 |
% |
| 1027 |
% \end{thebibliography} |
| 1028 |
% |
| 1029 |
% \end{documentation} |
| 1030 |
% |
| 1031 |
% \begin{implementation} |
| 1032 |
% |
| 1033 |
% \section{\pkg{expl3} implementation} |
| 1034 |
% |
| 1035 |
% The implementation here covers several things. There are two |
| 1036 |
% \enquote{loaders} to define: the parts of the code that are specific to |
| 1037 |
% \LaTeXe{} or to non-\LaTeXe{} formats. These have to cover the same |
| 1038 |
% concepts as each other but in rather different ways: as a result, much |
| 1039 |
% of the code is given in separate blocks. There is also a short piece of |
| 1040 |
% code for the start of the \enquote{payload}: this is to ensure that |
| 1041 |
% loading is always done in the right way. |
| 1042 |
% |
| 1043 |
% \subsection{Loader interlock} |
| 1044 |
% |
| 1045 |
% A short piece of set up to check that the loader and \enquote{payload} |
| 1046 |
% versions match. |
| 1047 |
% |
| 1048 |
% \begin{macro}{\ExplLoaderFileDate} |
| 1049 |
% As DocStrip is used to generate \cs{ExplFileDate} |
| 1050 |
% for all files from the same source, it has to match. Thus the loaders |
| 1051 |
% simply save this information with a new name. |
| 1052 |
% \begin{macrocode} |
| 1053 |
%<*2ekernel|generic|package> |
| 1054 |
\let\ExplLoaderFileDate\ExplFileDate |
| 1055 |
%</2ekernel|generic|package> |
| 1056 |
% \end{macrocode} |
| 1057 |
% \end{macro} |
| 1058 |
% |
| 1059 |
% \begin{macro}{\c__kernel_expl_date_tl} |
| 1060 |
% The \LaTeXe{} loader stores a private copy of \cs{ExplFileDate}, |
| 1061 |
% which is fixed when the format is build and cannot be changed later. |
| 1062 |
% While \cs{ExplFileDate} ensures that the loader (either |
| 1063 |
% \texttt{2ekernel} or \texttt{package}) version matches the version |
| 1064 |
% of \file{expl3-code.tex}, this one ensures that the version of an |
| 1065 |
% eventual |\usepackage{expl3}| matches the version from the format. |
| 1066 |
% It seems to be common to have stray format files in the user tree |
| 1067 |
% which trigger errors due to mismatched versions (\emph{e.g.} |
| 1068 |
% \url{https://github.com/latex3/latex3/issues/781}). |
| 1069 |
% |
| 1070 |
% This block also goes to the generic loader, as \pkg{expl3} isn't |
| 1071 |
% preloaded there, so the kernel date should be equal to the loader |
| 1072 |
% date. |
| 1073 |
% \begin{macrocode} |
| 1074 |
%<*2ekernel|generic> |
| 1075 |
\begingroup |
| 1076 |
\catcode`\_=11 |
| 1077 |
\expandafter |
| 1078 |
\ifx\csname c__kernel_expl_date_tl\endcsname\relax |
| 1079 |
\global\let\c__kernel_expl_date_tl\ExplFileDate |
| 1080 |
\fi |
| 1081 |
\endgroup |
| 1082 |
%</2ekernel|generic> |
| 1083 |
% \end{macrocode} |
| 1084 |
% \end{macro} |
| 1085 |
% |
| 1086 |
% The interlock test itself is simple: \cs{ExplLoaderFileDate} must be |
| 1087 |
% defined and identical to \cs{ExplFileDate}. As this has to work for |
| 1088 |
% both \LaTeXe{} and other formats, there is some auto-detection involved. |
| 1089 |
% (Done this way avoids having two very similar blocks for \LaTeXe{} and |
| 1090 |
% other formats.) |
| 1091 |
% \begin{macrocode} |
| 1092 |
%<*code> |
| 1093 |
\begingroup |
| 1094 |
\def\next{\endgroup}% |
| 1095 |
\expandafter\ifx\csname PackageError\endcsname\relax |
| 1096 |
\begingroup |
| 1097 |
\def\next{\endgroup\endgroup}% |
| 1098 |
\def\PackageError#1#2#3% |
| 1099 |
{% |
| 1100 |
\endgroup |
| 1101 |
\errhelp{#3}% |
| 1102 |
\errmessage{#1 Error: #2!}% |
| 1103 |
}% |
| 1104 |
\fi |
| 1105 |
\expandafter\ifx\csname ExplLoaderFileDate\endcsname\relax |
| 1106 |
\def\next |
| 1107 |
{% |
| 1108 |
\PackageError{expl3}{No expl3 loader detected} |
| 1109 |
{% |
| 1110 |
You have attempted to use the expl3 code directly rather than using |
| 1111 |
the correct loader. Loading of expl3 will abort. |
| 1112 |
}% |
| 1113 |
\endgroup |
| 1114 |
\endinput |
| 1115 |
} |
| 1116 |
\else |
| 1117 |
\ifx\ExplLoaderFileDate\ExplFileDate |
| 1118 |
\else |
| 1119 |
\def\next |
| 1120 |
{% |
| 1121 |
\PackageError{expl3}{Mismatched expl3 files detected} |
| 1122 |
{% |
| 1123 |
You have attempted to load expl3 with mismatched files: |
| 1124 |
probably you have one or more files 'locally installed' which |
| 1125 |
are in conflict. Loading of expl3 will abort. |
| 1126 |
}% |
| 1127 |
\endgroup |
| 1128 |
\endinput |
| 1129 |
}% |
| 1130 |
\fi |
| 1131 |
\fi |
| 1132 |
\next |
| 1133 |
%</code> |
| 1134 |
% \end{macrocode} |
| 1135 |
% |
| 1136 |
% A reload test for the payload, just in case. |
| 1137 |
% \begin{macrocode} |
| 1138 |
%<*code> |
| 1139 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 1140 |
\expandafter\ifx\csname [email protected]\endcsname\relax |
| 1141 |
\expandafter\edef\csname [email protected]\endcsname |
| 1142 |
{% |
| 1143 |
\ExplFileDate\space |
| 1144 |
L3 programming layer |
| 1145 |
}% |
| 1146 |
\else |
| 1147 |
\expandafter\endinput |
| 1148 |
\fi |
| 1149 |
%</code> |
| 1150 |
% \end{macrocode} |
| 1151 |
% |
| 1152 |
% All good: log the version of the code used (for log completeness). As this |
| 1153 |
% is more-or-less \cs{ProvidesPackage} without a separate file and as this also |
| 1154 |
% needs to work without \LaTeXe{}, just write the information directly to the |
| 1155 |
% log. |
| 1156 |
% \begin{macrocode} |
| 1157 |
%<*code> |
| 1158 |
\immediate\write-1 % |
| 1159 |
{% |
| 1160 |
Package: expl3 |
| 1161 |
\ExplFileDate\space |
| 1162 |
L3 programming layer (code)% |
| 1163 |
}% |
| 1164 |
%</code> |
| 1165 |
% \end{macrocode} |
| 1166 |
% |
| 1167 |
% \subsection{\LaTeXe{} loaders} |
| 1168 |
% |
| 1169 |
% Loading with \LaTeXe{} may be as part of the format (pre-loading) |
| 1170 |
% or as a package. We have to allow for both possible paths, and of |
| 1171 |
% course the package being loaded on to of the pre-load. That means |
| 1172 |
% the code here must be safe against re-loading. |
| 1173 |
% |
| 1174 |
% \begin{macrocode} |
| 1175 |
%<*2ekernel|package> |
| 1176 |
% \end{macrocode} |
| 1177 |
% |
| 1178 |
% Identify the package or add to the format message. |
| 1179 |
% \begin{macrocode} |
| 1180 |
%<*2ekernel> |
| 1181 |
\ifdefined\LaTeXReleaseInfo |
| 1182 |
\LaTeXReleaseInfo\expandafter{\the\LaTeXReleaseInfo |
| 1183 |
\show@release@info{L3 programming layer <\ExplFileDate>}% |
| 1184 |
}% |
| 1185 |
\else |
| 1186 |
\everyjob\expandafter{\the\everyjob |
| 1187 |
\message{L3 programming layer <\ExplFileDate>}% |
| 1188 |
}% |
| 1189 |
\fi |
| 1190 |
%</2ekernel> |
| 1191 |
%<*package> |
| 1192 |
\ProvidesPackage{expl3} |
| 1193 |
[% |
| 1194 |
\ExplFileDate\space |
| 1195 |
L3 programming layer (loader) |
| 1196 |
]% |
| 1197 |
%</package> |
| 1198 |
% \end{macrocode} |
| 1199 |
% |
| 1200 |
% \begin{macro}{\ProvidesExplPackage, \ProvidesExplClass, \ProvidesExplFile} |
| 1201 |
% For other packages and classes building on this one it is convenient |
| 1202 |
% not to need \cs{ExplSyntaxOn} each time. All macros use the same |
| 1203 |
% internal one with the proper \LaTeXe{} command. |
| 1204 |
% \begin{macrocode} |
| 1205 |
\protected\def\ProvidesExplPackage |
| 1206 |
{\@expl@provides@file@@Nnnnnn\ProvidesPackage{Package}} |
| 1207 |
\protected\def\ProvidesExplClass |
| 1208 |
{\@expl@provides@file@@Nnnnnn\ProvidesClass{Document Class}} |
| 1209 |
\protected\def\ProvidesExplFile |
| 1210 |
{\@expl@provides@file@@Nnnnnn\ProvidesFile{File}} |
| 1211 |
% \end{macrocode} |
| 1212 |
% \end{macro} |
| 1213 |
% |
| 1214 |
% \begin{macro}{\@expl@provides@file@@Nnnnnn} |
| 1215 |
% \begin{macro}{\@expl@provides@file@@N} |
| 1216 |
% \begin{macro}{\@expl@provides@generic@@wnnw} |
| 1217 |
% We need to check the existence of the |
| 1218 |
% \cs[no-index]{Provides\meta{thing}}, since we need to load this very |
| 1219 |
% early in the \LaTeXe{} kernel. The gymnastics with the version identifier |
| 1220 |
% argument allow for the case where it starts with a \texttt{v} and the one |
| 1221 |
% where it does not: formally the \texttt{v} is not part of the version, |
| 1222 |
% but a lot of people include it. |
| 1223 |
% \begin{macrocode} |
| 1224 |
\protected\long\def\@expl@provides@file@@Nnnnnn#1#2#3#4#5#6% |
| 1225 |
{% |
| 1226 |
\ifnum0% |
| 1227 |
\ifdefined#11\fi |
| 1228 |
\ifx\relax#1\else1\fi |
| 1229 |
=11 |
| 1230 |
\expandafter#1% |
| 1231 |
\else |
| 1232 |
\@expl@provides@generic@@wnnw{#2}% |
| 1233 |
\fi |
| 1234 |
{#3}[{#4 \ifx\relax#5\relax\else\@expl@provides@file@@N#5\space\fi #6}]% |
| 1235 |
\ExplSyntaxOn |
| 1236 |
} |
| 1237 |
\long\def\@expl@provides@file@@N#1{v\if#1v\else#1\fi} |
| 1238 |
\protected\long\def\@expl@provides@generic@@wnnw#1\fi#2[#3]% |
| 1239 |
{% |
| 1240 |
\immediate\write-1{#1: #2 #3}% |
| 1241 |
} |
| 1242 |
% \end{macrocode} |
| 1243 |
% \end{macro} |
| 1244 |
% \end{macro} |
| 1245 |
% \end{macro} |
| 1246 |
% |
| 1247 |
% Load the business end: this leaves \cs{expl3} syntax on. |
| 1248 |
% The test ensures we only load once without needing to know if |
| 1249 |
% there was a preloading step. |
| 1250 |
% \begin{macrocode} |
| 1251 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 1252 |
\expandafter\ifx\csname tex\string _let:D\endcsname\relax |
| 1253 |
\expandafter\@firstofone |
| 1254 |
\else |
| 1255 |
\expandafter\@gobble |
| 1256 |
\fi |
| 1257 |
{\input expl3-code.tex }% |
| 1258 |
% \end{macrocode} |
| 1259 |
% |
| 1260 |
% A check that the bootstrap code did not abort loading: if it did, |
| 1261 |
% bail out silently here. |
| 1262 |
% \begin{macrocode} |
| 1263 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 1264 |
\expandafter\ifx\csname tex\string _let:D\endcsname\relax |
| 1265 |
\expandafter\endinput |
| 1266 |
\fi |
| 1267 |
% \end{macrocode} |
| 1268 |
% |
| 1269 |
% \begin{macrocode} |
| 1270 |
%<@@=expl> |
| 1271 |
% \end{macrocode} |
| 1272 |
% |
| 1273 |
% At this point, if we have \cs{c__kernel_expl_date_tl} defined, just |
| 1274 |
% call the \cs{__kernel_dependency_version_check:Nn} auxiliary to check |
| 1275 |
% if it matches \cs{ExplLoaderFileDate}. Here the test is performed |
| 1276 |
% only if \cs{c__kernel_expl_date_tl} exists because this file can be |
| 1277 |
% loaded in a \LaTeXe{} format without \pkg{expl3} preloaded, where that |
| 1278 |
% token list doesn't exist. |
| 1279 |
% |
| 1280 |
% This is all done in the \texttt{package} \pkg{docstrip} guard because |
| 1281 |
% it doesn't apply to \pkg{expl3.ltx}. |
| 1282 |
% \begin{macrocode} |
| 1283 |
%<*package> |
| 1284 |
\ifcsname\detokenize{c__kernel_expl_date_tl}\endcsname |
| 1285 |
\expandafter\@firstofone |
| 1286 |
\else |
| 1287 |
% \end{macrocode} |
| 1288 |
% If \cs{c__kernel_expl_date_tl} does \emph{not} exist we may be loading |
| 1289 |
% in a format without \pkg{expl3} preloaded or in the earlier (although |
| 1290 |
% still compatible) version in which the error mentioned above showed |
| 1291 |
% up. If loading as a package, \file{expl3-code.tex} got read and here |
| 1292 |
% the \pkg{expl3} syntax is on. Otherwise it was already loaded in a |
| 1293 |
% slightly older kernel, so we fire the incompatibility error message and |
| 1294 |
% abort loading. |
| 1295 |
% \begin{macrocode} |
| 1296 |
\ifodd\csname\detokenize{l__kernel_expl_bool}\endcsname |
| 1297 |
% \end{macrocode} |
| 1298 |
% In package mode all files are loaded in one go, so versions will |
| 1299 |
% match. We just have to set \cs{c__kernel_expl_date_tl} so that |
| 1300 |
% further dependencies don't break: |
| 1301 |
% \begin{macrocode} |
| 1302 |
\global\expandafter\let\csname\detokenize |
| 1303 |
{c__kernel_expl_date_tl}\endcsname\ExplLoaderFileDate |
| 1304 |
\expandafter\expandafter |
| 1305 |
\expandafter\@gobble |
| 1306 |
\else |
| 1307 |
% \end{macrocode} |
| 1308 |
% And reloading in an incompatible version is an error: |
| 1309 |
% \begin{macrocode} |
| 1310 |
\expandafter\expandafter |
| 1311 |
\expandafter\@firstofone |
| 1312 |
\fi |
| 1313 |
\fi |
| 1314 |
{\csname\detokenize{__kernel_dependency_version_check:Nn}\endcsname |
| 1315 |
\ExplLoaderFileDate{expl3.sty}}% |
| 1316 |
%</package> |
| 1317 |
% \end{macrocode} |
| 1318 |
% |
| 1319 |
% Here we can also detect whether we're reloading. This code goes into |
| 1320 |
% \texttt{expl3.ltx} and \texttt{expl3.sty}, the former loaded into the |
| 1321 |
% \LaTeXe{} format. When this code is loaded for the first time, the |
| 1322 |
% \cs{g_@@_reload_bool} boolean doesn't exist (\cs{else} branch of the |
| 1323 |
% \cs{ifcsname} below), so we create it. If the \cs{ifcsname} is true, |
| 1324 |
% then we do \cs{ExplSyntaxOn} (because when reloading, |
| 1325 |
% \texttt{expl3-code.tex} isn't read again), and set |
| 1326 |
% \cs{g_@@_reload_bool} to true. |
| 1327 |
% \begin{macrocode} |
| 1328 |
\ifcsname\detokenize{g_@@_reload_bool}\endcsname |
| 1329 |
\ExplSyntaxOn |
| 1330 |
\bool_gset_true:N \g_@@_reload_bool |
| 1331 |
\else |
| 1332 |
\bool_new:N \g_@@_reload_bool |
| 1333 |
\fi |
| 1334 |
% \end{macrocode} |
| 1335 |
% |
| 1336 |
% \begin{variable}{\c_@@_def_ext_tl} |
| 1337 |
% Needed by \LaTeXe{}, and avoiding a re-load issue. Variables are |
| 1338 |
% best checked explicitly, rather than with \cs{g_@@_reload_bool} |
| 1339 |
% because some appear only in one of the code files, so |
| 1340 |
% \cs{g_@@_reload_bool} doesn't necessarily mean that the variable |
| 1341 |
% is already declared. |
| 1342 |
% \begin{macrocode} |
| 1343 |
\tl_if_exist:NF \c_@@_def_ext_tl |
| 1344 |
{ \tl_const:Nn \c_@@_def_ext_tl { def } } |
| 1345 |
% \end{macrocode} |
| 1346 |
% \end{variable} |
| 1347 |
% |
| 1348 |
% \begin{macro} |
| 1349 |
% {\__kernel_sys_configuration_load:n,\__kernel_sys_configuration_load_std:n} |
| 1350 |
% To load configurations, we have the following cases |
| 1351 |
% \begin{itemize} |
| 1352 |
% \item \pkg{expl3} is pre-loaded: by the time any configuration loads, |
| 1353 |
% we have the full file loading stack, and only need the standard |
| 1354 |
% version of the code here. |
| 1355 |
% \item The package is loaded with pre-loading: we again use the standard |
| 1356 |
% version, but we don't test just yet. |
| 1357 |
% \item The package is used without pre-loaded code: we need to manually |
| 1358 |
% manage \pkg{expl3} syntax. |
| 1359 |
% \end{itemize} |
| 1360 |
% \begin{macrocode} |
| 1361 |
\cs_gset_protected:Npn \__kernel_sys_configuration_load:n #1 |
| 1362 |
%<*!2ekernel> |
| 1363 |
{ |
| 1364 |
\ExplSyntaxOff |
| 1365 |
\cs_undefine:c { ver@ #1 .def } |
| 1366 |
\@onefilewithoptions {#1} [ ] [ ] |
| 1367 |
\c_@@_def_ext_tl |
| 1368 |
\ExplSyntaxOn |
| 1369 |
} |
| 1370 |
\cs_gset_protected:Npn \__kernel_sys_configuration_load_std:n #1 |
| 1371 |
%</!2ekernel> |
| 1372 |
{ |
| 1373 |
\cs_undefine:c { ver@ #1 .def } |
| 1374 |
\@onefilewithoptions {#1} [ ] [ ] |
| 1375 |
\c_@@_def_ext_tl |
| 1376 |
} |
| 1377 |
% \end{macrocode} |
| 1378 |
% \end{macro} |
| 1379 |
% |
| 1380 |
% \begin{variable}{\l_@@_options_clist} |
| 1381 |
% \begin{macrocode} |
| 1382 |
%<*!2ekernel> |
| 1383 |
\clist_if_exist:NF \l_@@_options_clist |
| 1384 |
{ \clist_new:N \l_@@_options_clist } |
| 1385 |
\DeclareOption* |
| 1386 |
{ \clist_put_right:NV \l_@@_options_clist \CurrentOption } |
| 1387 |
\ProcessOptions \relax |
| 1388 |
%</!2ekernel> |
| 1389 |
% \end{macrocode} |
| 1390 |
% \end{variable} |
| 1391 |
% |
| 1392 |
% Pretty standard setting creation. |
| 1393 |
% \begin{macrocode} |
| 1394 |
\keys_define:nn { sys } |
| 1395 |
{ |
| 1396 |
backend .choices:nn = |
| 1397 |
{ dvipdfmx , dvips , dvisvgm , luatex , pdftex , pdfmode , xdvipdfmx , xetex } |
| 1398 |
{ \sys_load_backend:n {#1} } , |
| 1399 |
check-declarations .choice: , |
| 1400 |
check-declarations / true .code:n = |
| 1401 |
{ \debug_on:n { check-declarations } } , |
| 1402 |
check-declarations / false .code:n = |
| 1403 |
{ |
| 1404 |
\__kernel_if_debug:TF |
| 1405 |
{ \debug_off:n { check-declarations } } |
| 1406 |
{ } |
| 1407 |
} , |
| 1408 |
check-declarations .default:n = true , |
| 1409 |
driver .meta:n = { backend = #1 } , |
| 1410 |
enable-debug .code:n = {} , % A stub |
| 1411 |
log-functions .choice: , |
| 1412 |
log-functions / true .code:n = |
| 1413 |
{ \debug_on:n { log-functions } } , |
| 1414 |
log-functions / false .code:n = |
| 1415 |
{ |
| 1416 |
\__kernel_if_debug:TF |
| 1417 |
{ \debug_off:n { log-functions } } |
| 1418 |
{ } |
| 1419 |
} , |
| 1420 |
log-functions .default:n = true , |
| 1421 |
suppress-backend-headers .bool_gset_inverse:N |
| 1422 |
= \g__kernel_backend_header_bool , |
| 1423 |
suppress-backend-headers .initial:n = false , |
| 1424 |
undo-recent-deprecations .code:n = {} % A stub |
| 1425 |
} |
| 1426 |
% \end{macrocode} |
| 1427 |
% |
| 1428 |
% \begin{macro}{\@expl@sys@load@backend@@@@} |
| 1429 |
% A backend has to be in place by the start of the document: this has |
| 1430 |
% to be before global options are checked for use. |
| 1431 |
% |
| 1432 |
% The \cs[no-index]{@expl@...@@@@} macros defined in this package are |
| 1433 |
% interfaces for \LaTeXe{}. There are currently (this will change |
| 1434 |
% with the next release of \LaTeXe{}) two possible cases, at this |
| 1435 |
% point of the code: either \cs{@expl@sys@load@backend@@@@} (and the |
| 1436 |
% others) already exist because they were defined in |
| 1437 |
% \texttt{ltexpl.ltx} (in \texttt{2ekernel} mode) or in |
| 1438 |
% \texttt{expl3.ltx} (in \texttt{package} mode). |
| 1439 |
% |
| 1440 |
% In \texttt{2ekernel} mode, if they exist we are using a future |
| 1441 |
% (2020-10-01) release of \LaTeXe{} and we don't need (and can't) |
| 1442 |
% patch \LaTeXe's internals because these commands are already there. |
| 1443 |
% Though if they don't exist in \texttt{2ekernel} mode, we're using |
| 1444 |
% an older version of the kernel, so we \emph{must} patch. |
| 1445 |
% |
| 1446 |
% In \texttt{package} mode, if these commands exist, then we are using |
| 1447 |
% a version of \LaTeXe{} with \pkg{expl3} preloaded (any version) |
| 1448 |
% and in any case patching is already done or the macros are in the |
| 1449 |
% format itself, so nothing to do. |
| 1450 |
% But if in \texttt{package} mode these macros don't exist, we have an |
| 1451 |
% even older version of \LaTeXe{} which doesn't even have |
| 1452 |
% \pkg{expl3} preloaded, so patching is necessary. |
| 1453 |
% |
| 1454 |
% All this means that in both \texttt{2ekernel} and \texttt{package} |
| 1455 |
% mode we have to check whether \cs{@expl@sys@load@backend@@@@} |
| 1456 |
% exists, and patch some \LaTeXe{} internals if it doesn't. |
| 1457 |
% |
| 1458 |
% In newer \LaTeXe{}, these macros have an empty definition in |
| 1459 |
% \texttt{ltexpl.dtx} in case something wrong happens while loading |
| 1460 |
% this file (\texttt{expl3.ltx}), so they can safely be used in the |
| 1461 |
% \LaTeXe{} kernel. |
| 1462 |
% |
| 1463 |
% \cs{@expl@sys@load@backend@@@@} is inserted right at the beginning |
| 1464 |
% of \cs{document}, but after closing the group started by \cs{begin}. |
| 1465 |
% When using \cs{tl_put_left:Nn} to patch the backend loading in |
| 1466 |
% \cs{document}, we need to make sure that it happens at group level |
| 1467 |
% zero, thus the strange |\endgroup...\begingroup| thing. |
| 1468 |
% |
| 1469 |
% This chunk of code should only be executed when loading |
| 1470 |
% \texttt{expl3.sty} in a \LaTeXe{} without \pkg{expl3} preloaded, so |
| 1471 |
% we check if \cs{@expl@sys@load@backend@@@@} exists. |
| 1472 |
% \begin{macrocode} |
| 1473 |
\cs_if_exist:NF \@expl@sys@load@backend@@@@ |
| 1474 |
{ |
| 1475 |
\tl_put_left:Nn \document |
| 1476 |
{ |
| 1477 |
\endgroup |
| 1478 |
\@expl@sys@load@backend@@@@ |
| 1479 |
\begingroup |
| 1480 |
} |
| 1481 |
} |
| 1482 |
% \end{macrocode} |
| 1483 |
% |
| 1484 |
% Now we define it anyhow. |
| 1485 |
% \begin{macrocode} |
| 1486 |
\cs_gset_protected:Npn \@expl@sys@load@backend@@@@ |
| 1487 |
{ |
| 1488 |
\str_if_exist:NF \c_sys_backend_str |
| 1489 |
{ \sys_load_backend:n { } } |
| 1490 |
} |
| 1491 |
% \end{macrocode} |
| 1492 |
% \end{macro} |
| 1493 |
% |
| 1494 |
% Process package options. |
| 1495 |
% \begin{macrocode} |
| 1496 |
%<*!2ekernel> |
| 1497 |
\keys_set:nV { sys } \l_@@_options_clist |
| 1498 |
\str_if_exist:NF \c_sys_backend_str |
| 1499 |
{ \sys_load_backend:n { } } |
| 1500 |
%</!2ekernel> |
| 1501 |
% \end{macrocode} |
| 1502 |
% |
| 1503 |
% \begin{macrocode} |
| 1504 |
%<*!2ekernel> |
| 1505 |
\bool_if:NT \g_@@_reload_bool |
| 1506 |
{ |
| 1507 |
\cs_gset_eq:NN \__kernel_sys_configuration_load:n |
| 1508 |
\__kernel_sys_configuration_load_std:n |
| 1509 |
\ExplSyntaxOff |
| 1510 |
\file_input_stop: |
| 1511 |
} |
| 1512 |
%</!2ekernel> |
| 1513 |
% \end{macrocode} |
| 1514 |
% |
| 1515 |
% Load the dynamic part of the code, either now or during the next run. |
| 1516 |
% \begin{macrocode} |
| 1517 |
\cs_if_free:cTF { [email protected] } |
| 1518 |
{ |
| 1519 |
\tex_everyjob:D \exp_after:wN |
| 1520 |
{ |
| 1521 |
\tex_the:D \tex_everyjob:D |
| 1522 |
\__kernel_sys_everyjob: |
| 1523 |
} |
| 1524 |
} |
| 1525 |
{ \__kernel_sys_everyjob: } |
| 1526 |
% \end{macrocode} |
| 1527 |
% |
| 1528 |
% \begin{variable}{\s_@@_stop} |
| 1529 |
% Internal scan marks. This code has to be reload-safe, so this one |
| 1530 |
% has to be guarded with \cs{if_cs_exist:N} (\cs{cs_if_exist:NF}) wouldn't |
| 1531 |
% do because it returns false for control sequences equal to \cs{scan_stop:}. |
| 1532 |
% \begin{macrocode} |
| 1533 |
\reverse_if:N \if_cs_exist:N \s_@@_stop |
| 1534 |
\scan_new:N \s_@@_stop |
| 1535 |
\fi: |
| 1536 |
% \end{macrocode} |
| 1537 |
% \end{variable} |
| 1538 |
% |
| 1539 |
% \begin{macro}{\@pushfilename, \@popfilename} |
| 1540 |
% \begin{macro}{\@@_status_pop:w} |
| 1541 |
% \begin{macro}{\@expl@push@filename@@@@} |
| 1542 |
% \begin{macro}{\@expl@push@filename@aux@@@@} |
| 1543 |
% \begin{macro}{\@expl@pop@filename@@@@} |
| 1544 |
% The idea here is to use \LaTeXe{}'s \tn{@pushfilename} and |
| 1545 |
% \tn{@popfilename} to track the current syntax status. This can be |
| 1546 |
% achieved by saving the current status flag at each push to a stack, |
| 1547 |
% then recovering it at the pop stage and checking if the code |
| 1548 |
% environment should still be active. |
| 1549 |
% |
| 1550 |
% Here the code follows the same patching logic than above for |
| 1551 |
% \cs{@expl@sys@load@backend@@@@}. |
| 1552 |
% \begin{macrocode} |
| 1553 |
\cs_if_exist:NF \@expl@push@filename@@@@ |
| 1554 |
{ |
| 1555 |
\tl_put_left:Nn \@pushfilename { \@expl@push@filename@@@@ } |
| 1556 |
\tl_put_right:Nn \@pushfilename { \@expl@push@filename@aux@@@@ } |
| 1557 |
} |
| 1558 |
\cs_gset_protected:Npn \@expl@push@filename@@@@ |
| 1559 |
{ |
| 1560 |
\exp_args:Ne \__kernel_file_input_push:n |
| 1561 |
{ |
| 1562 |
\tl_to_str:N \@currname . |
| 1563 |
\tl_to_str:N \@currext |
| 1564 |
} |
| 1565 |
\tl_put_left:Ne \l_@@_status_stack_tl |
| 1566 |
{ |
| 1567 |
\bool_if:NTF \l__kernel_expl_bool |
| 1568 |
{ 1 } |
| 1569 |
{ 0 } |
| 1570 |
} |
| 1571 |
\ExplSyntaxOff |
| 1572 |
} |
| 1573 |
% \end{macrocode} |
| 1574 |
% This bit of trickery is needed to grab the name of the file being loaded |
| 1575 |
% so we can record it. |
| 1576 |
% \begin{macrocode} |
| 1577 |
\cs_gset_protected:Npn \@expl@push@filename@aux@@@@ #1#2#3 |
| 1578 |
{ |
| 1579 |
\str_gset:Nn \g_file_curr_name_str {#3} |
| 1580 |
#1 #2 {#3} |
| 1581 |
} |
| 1582 |
% \end{macrocode} |
| 1583 |
% |
| 1584 |
% \begin{macrocode} |
| 1585 |
\cs_if_exist:NF \@expl@pop@filename@@@@ |
| 1586 |
{ |
| 1587 |
\tl_put_right:Nn \@popfilename |
| 1588 |
{ \@expl@pop@filename@@@@ } |
| 1589 |
} |
| 1590 |
\cs_gset_protected:Npn \@expl@pop@filename@@@@ |
| 1591 |
{ |
| 1592 |
\__kernel_file_input_pop: |
| 1593 |
\tl_if_empty:NTF \l_@@_status_stack_tl |
| 1594 |
{ \ExplSyntaxOff } |
| 1595 |
{ \exp_after:wN \@@_status_pop:w \l_@@_status_stack_tl \s_@@_stop } |
| 1596 |
} |
| 1597 |
% \end{macrocode} |
| 1598 |
% The pop auxiliary function removes the first item from the stack, |
| 1599 |
% saves the rest of the stack and then does the test. The flag here |
| 1600 |
% is not a proper \texttt{bool}, so a low-level test is used. |
| 1601 |
% \begin{macrocode} |
| 1602 |
\cs_gset_protected:Npn \@@_status_pop:w #1#2 \s_@@_stop |
| 1603 |
{ |
| 1604 |
\tl_set:Nn \l_@@_status_stack_tl {#2} |
| 1605 |
\int_if_odd:nTF {#1} |
| 1606 |
{ \ExplSyntaxOn } |
| 1607 |
{ \ExplSyntaxOff } |
| 1608 |
} |
| 1609 |
% \end{macrocode} |
| 1610 |
% \end{macro} |
| 1611 |
% \end{macro} |
| 1612 |
% \end{macro} |
| 1613 |
% \end{macro} |
| 1614 |
% \end{macro} |
| 1615 |
% |
| 1616 |
% \begin{variable}{\l_@@_status_stack_tl} |
| 1617 |
% As \pkg{expl3} itself cannot be loaded with the code environment |
| 1618 |
% already active, at the end of the package \cs{ExplSyntaxOff} can |
| 1619 |
% safely be called. |
| 1620 |
% \begin{macrocode} |
| 1621 |
\tl_if_exist:NF \l_@@_status_stack_tl |
| 1622 |
{ |
| 1623 |
\tl_new:N \l_@@_status_stack_tl |
| 1624 |
\tl_set:Nn \l_@@_status_stack_tl { 0 } |
| 1625 |
} |
| 1626 |
% \end{macrocode} |
| 1627 |
% \end{variable} |
| 1628 |
% |
| 1629 |
% Tidy up configuration loading, as promised. |
| 1630 |
% \begin{macrocode} |
| 1631 |
%<*!2ekernel> |
| 1632 |
\cs_gset_eq:NN \__kernel_sys_configuration_load:n |
| 1633 |
\__kernel_sys_configuration_load_std:n |
| 1634 |
%</!2ekernel> |
| 1635 |
% \end{macrocode} |
| 1636 |
% |
| 1637 |
% For pre-loading, we have to manually disable the syntax. |
| 1638 |
% \begin{macrocode} |
| 1639 |
%<*2ekernel> |
| 1640 |
\ExplSyntaxOff |
| 1641 |
%</2ekernel> |
| 1642 |
% \end{macrocode} |
| 1643 |
% |
| 1644 |
% \begin{macrocode} |
| 1645 |
%</2ekernel|package> |
| 1646 |
% \end{macrocode} |
| 1647 |
% |
| 1648 |
% \subsection{Generic loader} |
| 1649 |
% |
| 1650 |
% \begin{macrocode} |
| 1651 |
%<*generic> |
| 1652 |
% \end{macrocode} |
| 1653 |
% |
| 1654 |
% The generic loader starts with a test to ensure that the current format is |
| 1655 |
% not \LaTeXe{}! |
| 1656 |
% \begin{macrocode} |
| 1657 |
\begingroup |
| 1658 |
\def\tempa{LaTeX2e}% |
| 1659 |
\def\next{}% |
| 1660 |
\ifx\fmtname\tempa |
| 1661 |
\def\next |
| 1662 |
{% |
| 1663 |
\PackageInfo{expl3}{Switching from generic to LaTeX2e loader}% |
| 1664 |
% \end{macrocode} |
| 1665 |
% The \cs{relax} stops \cs{RequirePackage} from scanning for a date |
| 1666 |
% argument. Putting \tn{endinput} \emph{after} loading the package is |
| 1667 |
% crucial, as otherwise \tn{endinput} would close the file |
| 1668 |
% \file{expl3.sty} at the end of its first line: indeed, as long as |
| 1669 |
% \file{expl3.sty} is open it is impossible to close the file |
| 1670 |
% \file{expl3-generic.tex}. |
| 1671 |
% \begin{macrocode} |
| 1672 |
\RequirePackage{expl3}\relax \endinput |
| 1673 |
}% |
| 1674 |
\fi |
| 1675 |
\expandafter\endgroup |
| 1676 |
\next |
| 1677 |
% \end{macrocode} |
| 1678 |
% |
| 1679 |
% Reload check and identify the package: |
| 1680 |
% no \LaTeXe{} mechanism so this is all pretty basic. |
| 1681 |
% \begin{macrocode} |
| 1682 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 1683 |
\expandafter\ifx\csname [email protected]\endcsname\relax |
| 1684 |
\else |
| 1685 |
\immediate\write-1 |
| 1686 |
{% |
| 1687 |
Package expl3 Info: The package is already loaded.% |
| 1688 |
}% |
| 1689 |
\expandafter\endinput |
| 1690 |
\fi |
| 1691 |
\immediate\write-1 |
| 1692 |
{% |
| 1693 |
Package: expl3 |
| 1694 |
\ExplFileDate\space |
| 1695 |
L3 programming layer (loader)% |
| 1696 |
}% |
| 1697 |
\expandafter\edef\csname [email protected]\endcsname |
| 1698 |
{\ExplFileDate\space L3 programming layer}% |
| 1699 |
% \end{macrocode} |
| 1700 |
% |
| 1701 |
% \begin{macrocode} |
| 1702 |
\ifnum\currentgrouplevel=0 % |
| 1703 |
\else |
| 1704 |
\errhelp{expl3 cannot be loaded inside a group: |
| 1705 |
reading the code has been aborted.}% |
| 1706 |
\errmessage{expl3 Error: Loading attempted inside a group!}% |
| 1707 |
\expandafter\endinput |
| 1708 |
\fi |
| 1709 |
% \end{macrocode} |
| 1710 |
% |
| 1711 |
% \begin{variable}[int]{\l@expl@tidy@tl} |
| 1712 |
% Save the category code of |@| and then set it to \enquote{letter}. |
| 1713 |
% \begin{macrocode} |
| 1714 |
\expandafter\edef\csname l@expl@tidy@tl\endcsname |
| 1715 |
{% |
| 1716 |
\catcode64=\the\catcode64\relax |
| 1717 |
\let\expandafter\noexpand\csname l@expl@tidy@tl\endcsname |
| 1718 |
\noexpand\undefined |
| 1719 |
}% |
| 1720 |
\catcode64=11 % |
| 1721 |
% \end{macrocode} |
| 1722 |
% \end{variable} |
| 1723 |
% |
| 1724 |
% \begin{macro}{\AtBeginDocument} |
| 1725 |
% \begin{macro}[int]{\expl@AtBeginDocument} |
| 1726 |
% There are a few uses of \cs{AtBeginDocument} in the package code: the |
| 1727 |
% easiest way around that is to simply do the code \enquote{now}. As |
| 1728 |
% bundles such as \pkg{miniltx} may have defined \cs{AtBeginDocument} |
| 1729 |
% any existing definition is saved for restoration after the payload. |
| 1730 |
% \begin{macrocode} |
| 1731 |
\let\expl@AtBeginDocument\AtBeginDocument |
| 1732 |
\def\AtBeginDocument#1{#1}% |
| 1733 |
\expandafter\def\expandafter\l@expl@tidy@tl\expandafter |
| 1734 |
{% |
| 1735 |
\l@expl@tidy@tl |
| 1736 |
\let\AtBeginDocument\expl@AtBeginDocument |
| 1737 |
\let\expl@AtBeginDocument\undefined |
| 1738 |
}% |
| 1739 |
% \end{macrocode} |
| 1740 |
% \end{macro} |
| 1741 |
% \end{macro} |
| 1742 |
% |
| 1743 |
% Load the business end: this leaves \cs{expl3} syntax on. |
| 1744 |
% \begin{macrocode} |
| 1745 |
\input expl3-code.tex % |
| 1746 |
% \end{macrocode} |
| 1747 |
% |
| 1748 |
% A check that the bootstrap code did not abort loading: if it did, |
| 1749 |
% bail out silently here. |
| 1750 |
% \begin{macrocode} |
| 1751 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 1752 |
\expandafter\ifx\csname tex\string _let:D\endcsname\relax |
| 1753 |
\expandafter\endinput |
| 1754 |
\fi |
| 1755 |
% \end{macrocode} |
| 1756 |
% |
| 1757 |
% \begin{macro}{\__kernel_sys_configuration_load:n} |
| 1758 |
% Very basic. |
| 1759 |
% \begin{macrocode} |
| 1760 |
\cs_gset_protected:Npn \__kernel_sys_configuration_load:n #1 |
| 1761 |
{ |
| 1762 |
\group_begin: |
| 1763 |
\cs_set_protected:Npn \ProvidesExplFile |
| 1764 |
{ |
| 1765 |
\char_set_catcode_space:n { `\ } |
| 1766 |
\ProvidesExplFileAux |
| 1767 |
} |
| 1768 |
\cs_set_protected:Npn \ProvidesExplFileAux ##1##2##3##4 |
| 1769 |
{ |
| 1770 |
\group_end: |
| 1771 |
\iow_log:e { File:~##1~##2~v##3~##4 } |
| 1772 |
} |
| 1773 |
\tex_input:D #1 .def \scan_stop: |
| 1774 |
} |
| 1775 |
% \end{macrocode} |
| 1776 |
% \end{macro} |
| 1777 |
% |
| 1778 |
% \begin{macro}{\g__kernel_backend_header_bool} |
| 1779 |
% Load the dynamic code and standard back-end. |
| 1780 |
% \begin{macrocode} |
| 1781 |
\__kernel_sys_everyjob: |
| 1782 |
\bool_new:N \g__kernel_backend_header_bool |
| 1783 |
\bool_gset_true:N \g__kernel_backend_header_bool |
| 1784 |
\sys_load_backend:n { } |
| 1785 |
% \end{macrocode} |
| 1786 |
% \end{macro} |
| 1787 |
% |
| 1788 |
% For the generic loader, a few final steps to take. Turn of \cs{expl3} |
| 1789 |
% syntax and tidy up the small number of temporary changes. |
| 1790 |
% \begin{macrocode} |
| 1791 |
\ExplSyntaxOff |
| 1792 |
\l@expl@tidy@tl |
| 1793 |
% \end{macrocode} |
| 1794 |
% |
| 1795 |
% \begin{macrocode} |
| 1796 |
%</generic> |
| 1797 |
% \end{macrocode} |
| 1798 |
% |
| 1799 |
% \end{implementation} |
| 1800 |
% |
| 1801 |
% \PrintIndex |