summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/expl3/test3.tex
blob: 3dd5f714d35be21fa0ae7ee37966a018a0d99f9d (plain)
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
% \iffalse
%% File: test2 Copyright (C) 1990-2006 LaTeX3 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
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the ``expl3 bundle'' (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/cgi-bin/cvsweb.cgi/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %% 
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
%%
% \fi
\documentclass{article}

\usepackage{l3precom}

% let's dump what is known about the LaTeX internals so far.
% this will not be much as the very basic stuff doesn't get
% dumped and we haven't got anything else.
%
\dumpLaTeXstate{test1}

\CodeStart

% we need some variants of tlp_set which are not yet
% defined for use in the code below.
%
\exp_def_form:nnn{tlp_set}{Nn}{on}
\exp_def_form:nnn{tlp_gset}{Nn}{on}

% okay, here we either load a dump file (testdump.cmp)
% and then jump tp \cs_dump: or we compile one for next time.
% don't forget that if you change code below it will only have any
% affect if a new dump file is written so you may have to remove
% the existing one.
%
\cs_load_dump:n{testdump}

% two test definitions
%
\def_new:Npn\foo{some foo}
\def_new:Npn\baz{some baz}

% we say that \foo should be dumped in the compiled style.
% this is pretty useless as it is certainly not faster than defining
% it in the first place. but this is only done for showing that it
% works. just assume that \foo is actually a pretty difficult
% definition which does need a lot of static compilation due to
% parsing, comparing values, etc., so that it is much faster load the
% final version rather than do the compilation each time again.
%
% btw note that \baz is not dumped and will not be available in the
% production run (ie the one using the cmp file)
%
\cs_record_name:N\foo

% get our self a scratch register (again this will not be available in
% the production run)
%
\tlp_new:Nn\l_scratch_tlp{}

% now we generate a unique cs name and assign it the string "foo".
% again pretty useless example. but with this mechansim you can build
% complex graph structures etc using these names as pointers, etc. and
% in such a case you need to dump the state of your graph at some
% point to be able to load it very fast in production.
%
\cs_gen_sym:N\l_scratch_tlp{}
\tlp_set:on \l_scratch_tlp {foo}

% ditto for a global unique name
%
\cs_ggen_sym:N\l_scratch_tlp{}
\tlp_gset:on \l_scratch_tlp {bar}

% and now we dump the whole rubbish. In the current implementation
% only csnames can be precompiled, perhaps registers should be handled
% similarly.
%
\cs_dump:

% and some int register to show something in the second LaTeX state
% dump.
%
\int_new:N\l_my_int
\int_set:Nn\l_my_int{42}
%
% as the allocation routines are not distributed we have to do this
% manually.
%
\register_record_name:N\l_my_int

\dumpLaTeXstate{test2}

% and changing something ... what happens with the LaTeX state?
%
\int_set:Nn\l_my_int{0}
\def:Npn\file_not_found:nTF#1#2#3{}

\dumpLaTeXstate{test3}

\CodeStop

\begin{document}

\LaTeX\ still works!

\end{document}