summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/expl3/test3.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/expl3/test3.tex')
-rw-r--r--Master/texmf-dist/doc/latex/expl3/test3.tex100
1 files changed, 100 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/expl3/test3.tex b/Master/texmf-dist/doc/latex/expl3/test3.tex
new file mode 100644
index 00000000000..8d3630839bb
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/expl3/test3.tex
@@ -0,0 +1,100 @@
+\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}
+
+
+
+