summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-10-25 22:26:36 +0000
committerKarl Berry <karl@freefriends.org>2015-10-25 22:26:36 +0000
commit2e5f14f60a516e247773eb44e16fdf71b24ffc6b (patch)
treedcf766a159ceb803ff37d6fc6093f14de9a57741 /Master
parentb21104f52f6a326c74adaf89be9b55745d4e65ba (diff)
lisp-on-tex (25oct15)
git-svn-id: svn://tug.org/texlive/trunk@38706 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE2
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/README278
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/README.md597
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.pdfbin0 -> 11875 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.tex30
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdfbin36636 -> 36632 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdfbin32299 -> 32295 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/nqueen.pdfbin12975 -> 12971 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdfbin30979 -> 30975 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/showfont.pdfbin13945 -> 13933 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/test.tex261
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/asts.tex9
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.pdfbin32056 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.tex79
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.pdfbin19112 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.tex15
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/ast.tex12
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.pdfbin32296 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.tex90
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.pdfbin19156 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.tex27
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.pdfbin8982 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.tex15
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.pdfbin32281 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.tex55
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.pdfbin19160 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.tex12
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.pdfbin8947 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.tex15
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.pdfbin45236 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.tex58
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.pdfbin19041 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.tex14
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.pdfbin1587 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.tex7
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.pdfbin45252 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.tex64
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.pdfbin19160 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.tex15
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/slide.tex213
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty65
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-cast.sty3
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-gc.sty197
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-latexutil.sty8
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-fpnum.sty21
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-l3regex.sty99
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-on-tex.sty858
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-prim.sty94
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-read.sty17
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-simple-alloc.sty32
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-string.sty17
-rw-r--r--Master/texmf-dist/tex/latex/lisp-on-tex/lisp-util.sty2
52 files changed, 1645 insertions, 1636 deletions
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE b/Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE
index 62d704d956e..e9b8a4b284d 100644
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE
@@ -6,7 +6,7 @@ lisp-read.sty, lisp-string.sty,
lisp-util.sty, lisp-mod-fpnum.sty,
fact.tex, rocket.tex, fpnummodule-mandelbrot.tex
-Copyright (c) 2012 2013 2014, HAKUTA Shizuya
+Copyright (c) 2012 2013 2014 2015 HAKUTA Shizuya
All rights reserved.
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/README b/Master/texmf-dist/doc/latex/lisp-on-tex/README
deleted file mode 100644
index d3cec712624..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/README
+++ /dev/null
@@ -1,278 +0,0 @@
-
-%%
-%% This is file `README'.
-%%
-%% License: Modified BSD - see LICENSE file.
-%%
-
-===== LISP on TeX --- A LISP interpreter on TeX ======
-Version 1.3
-Author : HAKUTA Shizuya <hak7a3@live.jp>
-
-==== Introduction ====
-LISP on TeX is a LISP interpreter written only with TeX macros.
-It works as a style file of LaTeX.
-LISP on TeX adopts static scoping, dynamic typing, and eager evaluation.
-We can program easily with LISP on TeX.
-
-==== Files ====
-
-README : This file.
---------------------------------------------------------------------------------------
-LICENCE : About LICENCE.
---------------------------------------------------------------------------------------
-lisp-on-tex.sty : Main routine. (evaluator)
---------------------------------------------------------------------------------------
-lisp-prim.sty : Primitive functions. (Automatically loaded by lisp.sty)
---------------------------------------------------------------------------------------
-lisp-read.sty : Parser. (Automatically loaded by lisp.sty)
---------------------------------------------------------------------------------------
-lisp-arith.sty : Arithmetical functions. (Automatically loaded by lisp.sty)
---------------------------------------------------------------------------------------
-lisp-string.sty : Functions which manipulates strings.
- : (Automatically loaded by lisp.sty)
---------------------------------------------------------------------------------------
-lisp-latexutil.sty : Utility functions for LaTeX.
- : (Automatically loaded by lisp.sty)
---------------------------------------------------------------------------------------
-lisp-util.sty : Utility functions written with LISP on TeX.
- : (Automatically loaded by lisp.sty)
---------------------------------------------------------------------------------------
-lisp-mod-fpnum.sty : The module which enables us to use fixed point numbers.
- : See the "Fixed Point Numbers" section in this document.
---------------------------------------------------------------------------------------
-test.tex : test code (using qstest.sty).
---------------------------------------------------------------------------------------
-examples/* : Example files. See the "Examples" section.
---------------------------------------------------------------------------------------
-tug2013/* : The slide and examples used on TUG2013.
---------------------------------------------------------------------------------------
-==== Usage ====
-To use LISP on TeX, write
-
- \usepackage{lisp}
-
-in the preamble of document.
-
-We can load module files
-using \usepackage. For example, the command
-
- \usepackage{lisp-mod-fpnum}
-
-loads the module of fixed point numbers.
-
-It the document, we can start LISP interpreter with \lispinterp.
-For example,
-
- \lispinterp{(\texprint :1)}
-
-outputs "1".
-
-To get more detail, please read example files.
-It is the better way to know about LISP on TeX.
-
-==== Examples ====
- * fact.tex
- -- Calculate the factorial function.
- * rocket.tex
- -- Show how to use "mutable" locations.
- * fpnum-mandelbrot.tex
- -- Calculate the mandelbrot set.
- -- It takes a long long time to typeset.
- * showfont.tex
- -- Show glyphs of selected font.
- -- It works on XeLaTeX.
- * repl.tex
- -- The Read-Eval-Print Loop interpretor of lisp-on-tex.
- * nqueen.tex
- -- Calculate 5-queens problem.
-
-==== Syntax ====
-The syntax of LISP on TeX is the following;
-
-<S-exp> ::= <cons>
- | <int>
- | <string>
- | <symbol>
- | <bool>
- | <nil>
- | <p-module>
- | <skip>
- | <dimen>
-<cons> ::= (<S-exp>+) | (<S-exp> . <S-exp>)
-<int> ::= :[TeX's integer]
-<string> ::= '[TeX's tokens]'
-<symbol> ::= [a control sequence]
-<bool> ::= /t | /f
-<nil> ::= ()
-<p-module>::= +{<modname>::<tokens>}
-<modname> ::= [TeX's tokens]
-<tokens> ::= [TeX's tokens]
-<skip> ::= @[TeX's skip]
-<dimen> ::= ![TeX's dimen]
-
-==== Functions and Others ====
-=== Special Forms ===
- * (\define \symbol <S-exp>)
- -- Binds the evaluation result of <S-exp> to \symbol.
- * (\lambda <ptn> <S-exp>)
- -- Lambda abstraction. The bind pattern <ptn> has the following syntax;
- <ptn> ::= <symbol> | (<symbol>*) | (<symbol>+ . <symbol>)
- * (\quote <S-exp>)
- -- Return <S-exp>.
- * (\lispif <S-exp 1> <S-exp 2> <S-exp 3>)
- -- Branch. The type of the evaluation result of <S-exp 1> must be bool.
- * (\defmacro \symbol <Lambda abstraction>)
- -- Define a macro.
- * (\begin <S-exp>+)
- -- Evaluate all arguments in a sequential order
- and returns the the evaluation result of the last argument.
- * (\defineM \symbol <S-exp>)
- -- Binds the evaluation result of <S-exp> to \symbol
- and the location which binds \symbol becomes "mutable".
- * (\setB \symbol <S-exp>)
- -- If location of which binds \symbol is "mutable",
- the evaluation result of <S-exp> is stored in the location.
-
-=== Evaluation ===
- * (\eval <S-exp>)
- -- Evaluate <S-exp> in the current environment.
- * (\apply <func> <list>)
- -- Evaluate (<func> <args>) where <list> = (<args>).
-
-=== Types ===
- * (\intQ <S-exp>)
- -- If the evaluation result of <S-exp> is an integer, it returns /t.
- Otherwise, it returns /f.
- -- Likewise, \pairQ, \booleanQ, \symbolQ, \stringQ, \dimenQ, \skipQ,
- \nilQ, \funcQ, \closureQ, and \macroQ are defined.
- * (\listQ <S-exp>)
- -- Return /t iff <S-exp> is a nil or a cons cell.
- Otherwise, it returns /f.
- * (\procedureQ <S-exp>)
- -- Return /t iff <S-exp> is a closure or a function (or a macro).
- * (\intTOstring <integer>)
- -- convert the argument into a string.
-
-=== Arithmetical Functions ===
- * (\+ <S-exp>*)
- -- Addition.
- -- If, the argument is empty, it returns 0.
- * (\- <S-exp>+)
- -- Subtraction.
- * (\* <S-exp>*)
- -- Multiplication.
- -- If, the argument is empty, it returns 1.
- * (\/ <S-exp>+)
- -- Division.
- * (\mod <int 1> <int 2>)
- -- Modulus.
- * (\< <S-exp 1> <S-exp 2>)
- -- Let n be the evaluation result of <S-exp 1> and m be that of <S-exp 2>.
- If n < m, it returns /t. Otherwise, it returns /f.
- * (\> <S-exp 1> <S-exp 2>)
- -- Let n be the evaluation result of <S-exp 1> and m be that of <S-exp 2>.
- If n > m, it returns /t. Otherwise, it returns /f.
- * (\leq <int 1> <int 2>)
- -- Return (<int 1> <= <int 2>)
- * (\geq <int 1> <int 2>)
- -- Return (<int 1> >= <int 2>)
- * (\isZeroQ <int>)
- -- Return (<int> == 0)
- * (\positiveQ <int>)
- -- Return (<int> > 0)
- * (\negativeQ <int>)
- -- Return (<int> < 0)
- * (\max <int 1> <int 2> ... )
- -- Return the max value of the arguments
- * (\min <int 1> <int 2> ... )
- -- Return the minimal value of the arguments
-
-=== Manipulation of Strings ===
- * (\concat <string 1> <string 2>)
- -- Concatenate two strings.
- * (\group <string>)
- -- Grouping.
- -- If <string> is 'foo\bar{baz}', it returns '{foo\bar{baz}}'.
- * (\ungroup <string>)
- -- Ungrouping.
- -- If <string> is '{foo\bar{baz}}', it returns 'foo\bar{baz}'.
- * (\expand <string>)
- -- Expand macros in string.
-
-=== Manipulation of Cons Cells ===
- * (\cons <S-exp 1> <S-exp 2>)
- -- Create a cons cell: the CAR of the cell is the evaluation result of
- <S-exp 1> and the CDR of the cell is the evaluation result of
- <S-exp 2>.
- * (\car <cons>)
- -- Get CAR part of the argument.
- * (\cdr <cons>)
- -- Get CAR part of the argument.
- * (\length <list>)
- -- If the argument is "list", count the length of the argument.
- -- We define the term "list" as following;
- - The value nil.
- - A cons cell whose CDR is "list".
- * (\nth <list> <int>)
- -- Get the <int>-th element of the <list>.
- -- The numbering starts from 0.
-
-=== Logical Functions ===
- * (\and <bool 1> <bopl 2> ...)
- * (\or <bool 1> <bopl 2> ...)
- * (\not <bool>)
-
-=== Misc ===
- * (\= <S-exp 1> <S-exp 2>)
- -- If the evaluation result of <S-exp 1> equals that of <S-exp 2>,
- it returns /t. Otherwise, it returns /f.
- * (\print <S-exp>)
- -- Write the evaluation result of <S-exp> as LISP on TeX form.
- * (\texprint <S-exp>)
- -- Write the evaluation result of <S-exp> as useful form in TeX.
- * (\immediatewrite)
- -- Flush the output buffer immediately.
- -- It may brake the evaluation routine.
- * (\message <str>)
- -- Write <str> to console.
- * (\map <proc> <list 1> <list 2> ...)
- -- Mapping function like Scheme's map.
- * (\let <bindings> <body>)
- -- Let bindings.
- * (\letM <bindings> <body>)
- -- Let bindings (mutable).
- * (\letrec <bindings> <body>)
- -- Let bindings (recursive and mutable).
-==== Fixed Point Numbers ====
- * +{fpnum::<fixed point number>}
- -- Create an fixed point number.
- * (\fpplus <S-exp>*)
- -- Addition.
- -- If, the argument is empty, it returns 0.0.
- * (\fpmunus <S-exp>+)
- -- Subtraction.
- * (\fpmul <S-exp>*)
- -- Multiplication.
- -- If, the argument is empty, it returns 1.0.
- * (\fplt <S-exp 1> <S-exp 2>)
- -- Let n be the evaluation result of <S-exp 1> and m be that of <S-exp 2>.
- If n < m, it returns /t. Otherwise, it returns /f.
-==== Continuations ====
- * (\callOCC <closure>)
- -- One shot continuations.
- -- It calls (<closure> c) where c is the current continuation.
-
-==== CHANGELOG ====
- * Jul. 12, 2014 : 1.3
- -- Add one shot continuations.
- -- Add some arithmetical functions.
- -- Debug environment.
- * Jan. 03, 2014 : 1.2
- -- Added TUG2013's examples.
- -- Improved the performance.
- * Aug. 10, 2013 : 1.1
- -- Added \letrec and \expand.
- -- debug
- * Mar. 04, 2013 : 1.0
- \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/README.md b/Master/texmf-dist/doc/latex/lisp-on-tex/README.md
new file mode 100644
index 00000000000..045f98aaed0
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/README.md
@@ -0,0 +1,597 @@
+# LISP on TeX #
+
+A LISP interpreter written only with TeX macros.
+It works as a style file of LaTeX.
+LISP on TeX adopts static scoping, dynamic typing, and eager evaluation.
+We can program easily with LISP on TeX.
+
+## Summary ##
+
+To use LISP on TeX, you should include the `lisp-on-tex` package.
+```
+\usepackage{lisp-on-tex}
+```
+
+If you do it, you can write LISP codes as a argument of `\lispinterp`.
+```
+\lispintrep{
+ (\some \LISP 'codes')
+ % example
+ (\define (\sum \a \b) (\+ \a \b))
+}
+```
+
+In LISP on TeX, a symbol is a control sequence;
+a string is tokens surrounded by quotation marks;
+and an integer is a TeX's integer using colon prefix.
+
+## Installation ##
+
+Put all files into your TEXMF tree.
+
+
+## Details ##
+
+### Class Options ###
+
+| Option Name | Meaning |
+| ----------- | ------------------------------- |
+| `noGC` | Never using GC (default) |
+| `markGC` | Using Mark-Sweep GC |
+| `GCopt=...` | Passing option to the GC engine |
+
+Currently, LISP on TeX supports Mark-Sweep GC.
+If you want to use it, you should use `markGC` option.
+You can also control heap size by using `GCopt={heapsize=n}`
+where `n` is greater than 3000. The default heap size is 32768.
+For example, the code
+```
+\usepackage[markGC, GCopt={heapsize=5000}]{lisp-on-tex}
+```
+shows that LISP on TeX uses Mark-Sweep GC and the heap size is 5000.
+
+### Syntax ###
+
+| Kinds | Literals | Examples |
+| ------------------ | ---------------------------------------------- | ---------------- |
+| CONS Cell | `(` *obj* ... `.` *obj* `)`, `(` *obj* ... `)` | `(\+ :1 :2)` |
+| Integer | `:` *TeX's integer* | `:42`, `:"3A` |
+| String | `'` *TeX's balanced tokens* `'` | `'\foo{bar}baz'` |
+| Symbol | *TeX's control sequence* | `\cs` |
+| Boolean | `/t` or `/f` | |
+| Nil | `()` | |
+| Skip | `@` *TeX's skip* | `@12pt plus 34cm`|
+| Dimen | `!` *TeX's dimen* | `!56pt` |
+
+### Functions and Special Forms ###
+
+#### Definition ####
+
+`\define` : Define a symbol.
+************************************
+
+```
+% symbol form
+(\define \foo :42) % ()
+\foo % :42
+% function form
+(\define (\foo \n) (\* \n :2))
+(\foo :3) % :6
+```
+
+`\defineM` : Define a mutable symbol.
+*************************************
+`\setB` : Rewrite a mutable symbol.
+*************************************
+
+```
+% symbol form
+(\defineM \foo :42) % ()
+\foo % :42
+(\setB \foo 'bar')
+\foo % 'bar'
+```
+
+`\defmacro` : Define a macro.
+*************************************
+`\macroexpand` : Expand a macro
+*************************************
+
+```
+(\defmacro (\foo \x) (\list (\quote \bar) \x \x \x)) % ()
+(\macroexpand (\quote (\foo :1))) % (\bar :1 :1 :1)
+```
+
+
+`\lambda` : Create a function.
+**************************************
+
+```
+% normal form
+((\lambda (\x) (\+ \x :2)) :3) % :5
+% list form
+((\lambda \x \x) :1 :2) % (:1 :2)
+% remain argument form
+((\lambda (\x . \y) \y) :1 :2 :3) % (:2 :3)
+```
+
+`\let` : Define local symbols.
+*****************************************
+
+```
+(\define \x 'foo')
+(\let ((\x :4) (\y :3)) (\+ \x \y)) % :7
+\x % 'foo'
+```
+
+`\letM` : Define mutable local symbols.
+******************************************
+
+```
+(\letM ((\x 'foo'))
+ (\begin (\setB \x 'bar') \x)) % 'bar'
+```
+
+`\letrec` : Define local symbols recursively.
+********************************************
+
+```
+(\letrec
+ ((\oddQ (\lambda (\n)
+ (\lispif (\= \n :0) /f (\evenQ (\- \n :1)))))
+ (\evenQ (\lambda (\n)
+ (\lispif (\= \n :0) /t (\oddQ (\- \n :1))))))
+ (\oddQ :42)) % /f
+```
+
+#### Control Flow ####
+
+`\lispif` : Branch.
+********************************************
+
+```
+(\lispif /t 'true' 'false') % 'true'
+(\lispif /f 'true' 'false') % 'false'
+```
+
+`\begin` : Execute expressions.
+********************************************
+
+```
+(\letM ((\x :1)) (\begin (\setB \s 'foo') \x))
+% 'foo'
+```
+
+`\callOCC` : One-shot continuation.
+*******************************************
+
+```
+(\defineM \x 'unchanged')
+(\callOCC (\lambda (\c)
+ (\begin (\c '\foo ')
+ (\setB \x 'changed')))) % '\foo '
+\x % 'unchanged'
+(\callOCC (\lambda (\c) :42)) % :42
+```
+
+#### String Manipulations ####
+
+`\concat` : Concatenate tokens.
+************************************
+
+```
+(\concat '$' '\foo ' '{bar}' '$') % '$\foo {bar}$'
+```
+
+`\intTOstring` : Convert a integer to TeX's tokens.
+******************************************************
+
+```
+(\intTOstring :42) % '42'
+```
+
+`\group` : Grouping.
+*******************************
+
+```
+(\group '\some {tokens}') % '{\some {tokens}}'
+```
+
+`\ungroup` : Ungrouping.
+************************
+
+```
+(\ungroup '{\some {tokens}}') % '\some {tokens}'
+```
+
+`\expand` : Expand tokens.
+******************************
+
+```
+\newcommand\foo[1]{I got #1!}
+\lispinterp{
+ (\expand '\foo{Foo}') % 'I got Foo!'
+}
+```
+
+#### Arithmetical Functions ####
+
+`\+` : Addition.
+***************************
+
+```
+(\+) % :0
+(\+ :1 :2) % :3
+(\+ :3 :4 :5) % :12
+```
+
+`\-` : Subtraction.
+************************
+
+```
+(\- :1) % :-1
+(\- :3 :2) % :1
+(\- :3 :2 :1) % :0
+```
+
+`\*` : Multiplication.
+**********************
+
+```
+(\*) % :1
+(\* :2 :3) % :6
+(\* :3 :4 :5) % :60
+```
+
+`\/` : Division.
+*************************
+
+```
+(\/ 2) % :0 (1/2 -> 0)
+(\/ 7 2) % :3
+```
+
+`\mod` : Modulo.
+*************************
+
+```
+(\mod :42 :23) % :19
+(\mod :3 :2) % :1
+(\mod :3 :-2) % :1
+(\mod :-3 :2) % :-1
+(\mod :-3 :-2) % :-1
+```
+
+`\>`, `\<`, `\geq`, `\leq` : Comparison.
+*******************************************
+
+```
+(\> :3 :2) % /t
+(\< :2 :3) % /t
+(\geq :3 :2) % /t
+(\geq :3 :3) % /t
+(\leq :2 :3) % /t
+(\leq :3 :3) % /t
+```
+
+Some predicates.
+************************
+
+```
+(\isZeroQ :0) % /t
+(\positiveQ :42) % /t
+(\negativeQ :-2) % /t
+```
+
+`\max` : Maximum.
+***************************
+
+```
+(\max :-10 :-5 :0 :5 :10) % :10
+```
+
+`\min` : Minimum.
+*****************************
+
+```
+(\min :-10 :-5 :0 :5 :10) % :-10
+```
+
+#### Logical functions ####
+
+`\and`, `\or`, `\not` : Logical and, or, not
+*********************************************
+
+```
+(\and /t /t) % /t
+(\and /t /f) % /f
+(\or /t /t) % /t
+(\or /t /f) % /t
+(\not /t) % /f
+```
+
+
+#### Traditional LISP Functions and Special Forms ####
+
+`\quote` : Quote.
+*******************
+
+```
+(\quote :42) % :42
+(\quote (\+ :1 :2)) % (\+ :1 :2)
+```
+
+`\cons`, `\car`, `\cdr` : CONS, CAR, CDR
+*************************************
+
+```
+(\cons :42 'foo') % (:42 . 'foo')
+(\car (\quote (:1 :2))) % :1
+(\cdr (\quote (:1 :2))) % (:2)
+```
+
+`\list` : Create a list
+***************************
+
+```
+(\list :1 :2 (\+ :3 :4)) % (:1 :2 :7)
+```
+
+`\length` : Get the length of a list.
+*****************************************
+
+```
+(\length ()) % :0
+(\length (\list :1 :2 'three')) % :3
+```
+
+`\map` : Map function.
+**************************
+
+```
+(\define (\f \x \y \z) (\+ \x \y \z))
+(\map \f (\list :1 :2 :3)
+ (\list :4 :5 :6)
+ (\list :7 :8 :9)) % (:12 :15 :18)
+```
+
+`\nth` : Get the n-th value of a list (starting with 0).
+***********************************************************
+
+```
+(\nth (\list 'foo' 'bar' 'baz') :1) % 'bar'
+```
+
+
+`\=` : Equality.
+*******************
+
+```
+(\= '42' :42) % /f
+(\= :23 :23) % /t
+(\= (\cons :1 'foo') (\cons :1 'foo')) % /f
+(\= 'foo' 'foo') % /t
+```
+`\texprint` : Convert a object to TeX's tokens and output it to the document
+******************************************************************************
+
+```
+(\texprint (\concat '\foo' (\group '42'))) % return () andoutput \foo{42}
+(\texprint :42) % output 42
+```
+
+`\print` : (For test) output a object as TeX's tokens
+*******************************************************
+
+```
+(\print ()) % output ()
+(\print (\quote \foo)) % output \string\foo
+(\print :42) % output :42
+(\print 'bar') % output 'bar'
+```
+
+Type predicates
+*********************
+
+```
+(\symbolQ (\quote \cs))
+(\stringQ 'foo')
+(\intQ :42)
+(\booleanQ /f)
+(\dimenQ !12pt)
+(\skipQ @12pt plus 1in minus 3mm)
+(\pairQ (\cons :1 :2))
+(\nilQ ())
+(\funcQ \+)
+(\closureQ (\lambda () ()))
+(\defmacro (\x) ())
+(\macroQ \x)
+(\listQ ())
+(\listQ (\list :1 :2))
+(\atomQ :23)
+(\atomQ 'bar')
+(\procedureQ \+)
+(\procedureQ (\lambda () ()))
+```
+
+#### LaTeX Utils ####
+
+`\readLaTeXCounter` : Read an integer from LaTeX
+***************************************************
+
+```
+\setcounter{foo}{42}
+\lispinterp{
+ (\readLaTeXCounter 'foo') % :42
+}
+```
+
+`\message` : Wrapper of LaTeX's \message
+*******************************************
+
+```
+(\message 'output') % output "message" to console and return ()
+```
+
+#### Others ####
+
+`\read` : Read a LISP expression from stdin
+*********************************************
+
+```
+(\read) % input :42 and return it
+```
+
+`\fgets` : Read a string from stdin.
+***************************************
+
+```
+(\fgets) % input \some {tokens} and return '\some {tokens}'
+```
+
+
+##Additional Packages ##
+
+### Fixed Point Numbers ###
+
+The package lisp-mod-fpnum adds fixed point numbers
+to LISP on TeX. Load it by `\usepackage`:
+
+```
+\usepackage{lisp-on-tex}
+\usepackage{lisp-mod-fpnum}
+```
+
+#### Syntax ####
+
+| Kinds | Literals | Examples |
+| ------------------ | ---------------------------------------------- | ---------------- |
+| Fixed point number | `+{fpnum::` *number* `}` | `+{fpnum::1.23}` |
+
+#### Functions ####
+
+`\fpnumTOstring` : Convert a fixed point number to a string.
+************************************************************
+
+```
+(\fpnumTOstring +{fpnum::1.23}) % '1.23'
+```
+
+`\fpplus` : Addition.
+*********************
+
+```
+(\fpplus +{fpnum::1.2} +{fpnum::1.4}) % 2.59999 (arithmetical error)
+```
+
+`\fpminus` : Subtraction.
+************************
+
+```
+(\fpminus +{fpnum::4.2} +{fpnum::2.3}) % 1.9
+```
+
+`\fpmul` : Multiplication.
+*****************************
+
+```
+(\fpmul +{fpnum::1.2} +{fpnum::1.4}) % 1.67998
+```
+
+`\fplt` : Comparison.
+**************************
+
+```
+(\fplt +{fpnum::1.2} +{fpnum::2.3}) % /t
+```
+
+
+### Regular Expressions ###
+
+The package lisp-mod-l3regex is thin wrapper
+of l3regex. Load it by `\usepackage`:
+
+```
+\usepackage{lisp-on-tex}
+\usepackage{lisp-mod-l3regex}
+```
+
+#### Functions ####
+
+`\regMatch`, `\regMatchResult` : Match.
+*************************************
+
+```
+(\regMatch 'hoge+' 'hogeeeeeee') % /t
+(\regMatchResult '(\w+)\s+is\s+(\w+)\.' 'He is crazy.')
+% ('He is crazy.' 'He' 'crazy')
+```
+
+`\regExtract` : Extraction.
+****************************
+
+```
+(\regExtract '\w+' 'hello regex world') % ('hello' 'regex' 'world')
+```
+
+`\regReplaceAll`, `\regReplaceOnce` : Replace.
+**********************************************
+
+```
+(\regReplaceAll '(\w+?)to(\w+?)' '$\1\c{to}\2$' 'AtoB BtoC') % '$A\to B$ $B\to C$'
+(\regReplaceOnce 'foo+' '[\0]' 'foooofooooooo') % '[foooo]fooooooo'
+```
+
+`\regSplit` : Split.
+***********************
+
+```
+(\regSplit '/' '/path/to/hogehoge') % ('' 'path' 'to' 'hogehoge')
+```
+
+
+## TODOs ##
+
+* Writing user manual
+* Add functions and special forms
+
+## CHANGELOG ##
+
+Oct. 25, 2015 : 2.0
+*************************
+
+* Add GC
+* Refine some special forms like \define
+* Add checking #args for some functions.
+* Add thin wrapper of l3regex
+
+Jul. 12, 2014 : 1.3
+*************************
+
+* Add one shot continuations.
+* Add some arithmetical functions.
+* Debug environment.
+
+Jan. 03, 2014 : 1.2
+**************************
+
+* Added TUG2013's examples.
+* Improved the performance.
+
+Aug. 10, 2013 : 1.1
+**************************
+
+* Added \letrec and \expand.
+* debug
+
+Mar. 04, 2013 : 1.0
+**************************
+
+## Licence ##
+
+Modified BSD (see LICENCE)
+
+************************************************
+HAKUTA Shizuya <hak7a3@live.jp>
+
+https://bitbucket.org/hak7a3/lisp-on-tex/
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.pdf
new file mode 100644
index 00000000000..6cb01f55aaa
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.tex
new file mode 100644
index 00000000000..ae2cf824ee6
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/div2.tex
@@ -0,0 +1,30 @@
+\documentclass{article}
+%\usepackage{lisp-on-tex}
+\usepackage[markGC]{lisp-on-tex}
+\lispinterp {
+ (\define (\create \n) (\createAcc \n ()))
+ (\define (\createAcc \n \acc)
+ (\lispif (\= \n :0) \acc (\createAcc (\- \n :1) (\cons () \acc))))
+ (\define \ll (\create :200))
+ (\define (\divII \l)
+ (\lispif (\= \l ()) () (\cons (\car \l) (\divII (\cdr (\cdr \l))))))
+ (\define (\test \l) (\testAcc \l :500)) % original is 300
+ (\define (\testAcc \l \i)
+ (\lispif (\= \i :0) ()
+ (\begin
+ (\lispif (\= (\length (\divII \l)) :100)
+ () (\texprint 'Hmm'))
+ (\lispif (\= (\length (\divII \l)) :100)
+ () (\message 'Hmm'))
+ (\lispif (\= (\length (\divII \l)) :100)
+ () (\message 'Hmm'))
+ (\lispif (\= (\length (\divII \l)) :100)
+ () (\message 'Hmm'))
+ (\texprint \i)
+ (\texprint ' ')
+ (\testAcc \l (\- \i :1)))))
+}
+
+\begin{document}
+ \lispinterp{(\test \ll)}
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdf
index 490cce4e5e8..5bb156ab393 100644
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdf
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdf
index 19359ec0385..b40e5f7c9b7 100644
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdf
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/nqueen.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/nqueen.pdf
index 89425e38a5b..c605d4212c8 100644
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/nqueen.pdf
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/nqueen.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdf
index de0e6ca70f6..bfff99d340a 100644
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdf
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/showfont.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/showfont.pdf
index 0960b7a9fed..13ef7fce56a 100644
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/showfont.pdf
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/showfont.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/test.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/test.tex
deleted file mode 100644
index 08b9171d3ab..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/test.tex
+++ /dev/null
@@ -1,261 +0,0 @@
-\documentclass{article}
-\usepackage{lisp-on-tex}
-\usepackage{qstest}
-\IncludeTests{*}
-\def\parserTestCallBack#1#2{\gdef\parsedResult{#1{#2}}}
-
-\begin{document}
- \LogTests{lgout}{*}{*}
- \makeatletter
- \begin{qstest}{Parser Test}{\@lispread}
- \begin{qstest}{cons and list}{\@lispread,\@tlabel@cons}
- % dot pair
- \def\subtestDot#1#2{\Expect{#1}{\@tlabel@cons}\subtestDotValue#2\relax\relax}%
- \def\subtestDotValue#1#2{%
- \expandafter\Expect\expandafter{#1}{\@tlabel@int{0}}%
- \expandafter\Expect\expandafter{#2}{\@tlabel@int{1}}}%
- \setbox0=\hbox{\@lispread\parserTestCallBack(:0.:1)}%
- \expandafter\subtestDot\parsedResult
- \Expect*{\the\wd0}{0.0pt}%
- % list
- \def\subtestListI#1#2{\Expect{#1}{\@tlabel@cons}\subtestListValueI#2\relax\relax}%
- \def\subtestListValueI#1#2{%
- \expandafter\Expect\expandafter{#1}{\@tlabel@int{1}}%
- \expandafter\subtestListII#2\relax\relax}%
- \def\subtestListII#1#2{\Expect{#1}{\@tlabel@cons}\subtestListValueII#2\relax\relax}%
- \def\subtestListValueII#1#2{%
- \expandafter\Expect\expandafter{#1}{\@tlabel@int{2}}%
- \expandafter\Expect\expandafter{#2}{\@tlabel@nil{}}}%
- \setbox0=\hbox{\@lispread\parserTestCallBack(:1 :2)}%
- \expandafter\subtestListI\parsedResult
- \Expect*{\the\wd0}{0.0pt}%
- % list with dot
- \def\subtestListDotI#1#2{\Expect{#1}{\@tlabel@cons}\subtestListDotValueI#2\relax\relax}%
- \def\subtestListDotValueI#1#2{%
- \expandafter\Expect\expandafter{#1}{\@tlabel@int{1}}%
- \expandafter\subtestListDotII#2\relax\relax}%
- \def\subtestListDotII#1#2{\Expect{#1}{\@tlabel@cons}\subtestListDotValueII#2\relax\relax}%
- \def\subtestListDotValueII#1#2{%
- \expandafter\Expect\expandafter{#1}{\@tlabel@int{2}}%
- \expandafter\Expect\expandafter{#2}{\@tlabel@int{3}}}%
- \setbox0=\hbox{\@lispread\parserTestCallBack(:1 :2.:3)}%
- \expandafter\subtestListDotI\parsedResult
- \Expect*{\the\wd0}{0.0pt}%
- \end{qstest}
- \def\parserTest#1#2{%
- \setbox0=\hbox{\@lispread\parserTestCallBack#1}%
- \expandafter\Expect\expandafter{\parsedResult}{#2}%
- \Expect*{\the\wd0}{0.0pt}%
- }
- \begin{qstest}{integer}{\@lispread,\@tlabel@int}
- \parserTest{:42}{\@tlabel@int{42}}
- \parserTest{:-42}{\@tlabel@int{-42}}
- \end{qstest}
- \begin{qstest}{string}{\@lispread,\@tlabel@string}
- \parserTest{'This is a {{example}} of \TeX : $f^{2x}_s(y)$'}
- {\@tlabel@string{This is a {{example}} of \TeX : $f^{2x}_s(y)$}}
- \end{qstest}
- \begin{qstest}{symbol}{\@lispread,\@tlabel@symbol}
- \parserTest{\symbol}{\@tlabel@symbol{\symbol}}
- \end{qstest}
- \begin{qstest}{bool}{\@lispread,\@tlabel@bool}
- \parserTest{/t}{\@tlabel@bool{t}}
- \parserTest{/f}{\@tlabel@bool{f}}
- \end{qstest}
- \begin{qstest}{nil}{\@lispread,\@tlabel@nil}
- \parserTest{()}{\@tlabel@nil{}}
- \end{qstest}
- \begin{qstest}{parser-module}{\@lispread}
- \def\@mod@read@dummy#1#2{\gdef#1{\@tlabel@testdummy{#2}}}
- \parserTest{+{dummy::testValue}}{\@tlabel@testdummy{testValue}}
- \end{qstest}
- \begin{qstest}{dimen}{\@lispread,\@tlabel@dimen}
- \parserTest{!123.45pt}{\@tlabel@dimen{123.45pt}}
- \end{qstest}
- \begin{qstest}{skip}{\@lispread,\@tlabel@skip}
- \parserTest{@123.45pt plus 1fil minus 0.5pt}
- {\@tlabel@skip{123.45pt plus 1.0fil minus 0.5pt}}
- \end{qstest}
- \end{qstest}
- \begin{qstest}{Evaluation}{\@lispeval}
- \begin{qstest}{self-evaluating form}{\@lispeval}
- \def\selfEvalTest#1{%
- \def\selfEvalTarget{#1}%
- \setbox0=\hbox{\lispeval\selfEvalTarget\selfEvalResult}%
- \Expect*{\the\wd0}{0.0pt}%
- \expandafter\expandafter\expandafter\Expect\expandafter\expandafter\expandafter{%
- \expandafter\selfEvalTarget\expandafter}\expandafter{\selfEvalResult}}%
- \selfEvalTest{\@tlabel@string{foo}}
- \selfEvalTest{\@tlabel@int{42}}
- \selfEvalTest{\@tlabel@bool{t}}
- \selfEvalTest{\@tlabel@dimen{12.3pt}}
- \selfEvalTest{\@tlabel@skip{12.3pt plus 1.0 fil minus 0.5pt}}
- \selfEvalTest{\@tlabel@nil{}}
- \selfEvalTest{\@tlabel@func{\dummy}}
- \selfEvalTest{\@tlabel@closure{{\x:\@@unused}{\y{\@ylabel@int{1}}}\@tlabel@int{0}}}
- \selfEvalTest{\@tlabel@macro{{\x:\@@unused}{}\@tlabel@int{0}}}
- \selfEvalTest{\@tlabel@envfunc{\dummy}}
- \selfEvalTest{\@tlabel@mutable{\dummy}}
- \selfEvalTest{\@tlabel@exception{3}}
- \selfEvalTest{\@tlabel@lambda{}}
- \selfEvalTest{\@tlabel@define{}}
- \selfEvalTest{\@tlabel@if{}}
- \selfEvalTest{\@tlabel@defmacro{}}
- \selfEvalTest{\@tlabel@begin{}}
- \selfEvalTest{\@tlabel@mdefine{}}
- \selfEvalTest{\@tlabel@setb{}}
- \selfEvalTest{\@tlabel@@let{}}
- \selfEvalTest{\@tlabel@@mlet{}}
- \selfEvalTest{\@tlabel@macroexpand{}}
- \selfEvalTest{\@tlabel@callocc{}}
- \selfEvalTest{\@tlabel@exception{{-1}{\@tlabel@string{dummy}}}}
- \selfEvalTest{\@tlabel@continuation{1}}
- \end{qstest}
- \begin{qstest}{symbol}{\@lispeval}
- %global env
- \def\selfEvalTarget{\@tlabel@symbol{\=}}%
- \setbox0=\hbox{\lispeval\selfEvalTarget\selfEvalResult}%
- \Expect*{\the\wd0}{0.0pt}%
- \expandafter\Expect\expandafter{\selfEvalResult}{\@tlabel@func{\@lisp@equal}}%
- % local env
- \def\selfEvalTarget{\@tlabel@symbol{\dummy}}%
- \setbox0=\hbox{\expandafter\@eval\selfEvalTarget{\dummy{\@tlabel@int{42}}}\selfEvalResult}%
- \Expect*{\the\wd0}{0.0pt}%
- \expandafter\Expect\expandafter{\selfEvalResult}{\@tlabel@int{42}}%
- % mutable
- \def\dummyMutable{\@tlabel@symbol{\dummy}}
- \setbox0=\hbox{\expandafter\@eval\selfEvalTarget{\dummy{\@tlabel@mutable{\dummyMutable}}}\selfEvalResult}%
- \Expect*{\the\wd0}{0.0pt}%
- expandafter\Expect\expandafter{\selfEvalResult}{\@tlabel@symbol{\dummy}}%
- \end{qstest}
- \begin{qstest}{cons cell and embeded function call}{\@lispeval}
- \@lispread\parserTestCallBack(\+ :1 :2)
- \setbox0=\hbox{\lispeval\parsedResult\consEvalResult}%
- \Expect*{\the\wd0}{0.0pt}%
- \expandafter\Expect\expandafter{\consEvalResult}{\@tlabel@int{3}}%
- \end{qstest}
- \begin{qstest}{special forms}{\@lispeval}
- \def\specialFormEval#1{%
- \@lispread\parserTestCallBack#1%
- \setbox0=\hbox{\lispeval\parsedResult\spEvalResult}%
- \Expect*{\the\wd0}{0.0pt}}
- %% defineM
- \def\getmdefSymbol#1\mdefSymbol#2#3\undefinedSymbol{%
- \def\postDefinedEnv{#1}%
- \def\testMdef{#2}%
- \def\preDefinedEnv{#3}}%
- \def\checkMdefinedValue#1#2#3{%
- \Expect{#1}{\@tlabel@mutable}%
- \expandafter\Expect\expandafter{#2}{#3}%
- }
- \toks0\expandafter{\@globalenv}%
- \specialFormEval{(\defineM \mdefSymbol :42)}% it is also used for setB, if, and begin
- \expandafter\getmdefSymbol\@globalenv\undefinedSymbol
- \expandafter\Expect\expandafter{\postDefinedEnv}{}%
- \expandafter\Expect\expandafter{\preDefinedEnv}*{\the\toks0}%
- \expandafter\checkMdefinedValue\testMdef{\@tlabel@int{42}}%
- %% setB
- \specialFormEval{(\setB \mdefSymbol 'hoge')}%
- \expandafter\getmdefSymbol\@globalenv\undefinedSymbol
- \expandafter\checkMdefinedValue\testMdef{\@tlabel@string{hoge}}%
- %% if
- \specialFormEval{(\lispif /t (\setB \mdefSymbol :1) (\setB \mdefSymbol :2))}%
- \expandafter\getmdefSymbol\@globalenv\undefinedSymbol
- \expandafter\checkMdefinedValue\testMdef{\@tlabel@int{1}}%
- \specialFormEval{(\lispif /f (\setB \mdefSymbol :1) (\setB \mdefSymbol :2))}%
- \expandafter\getmdefSymbol\@globalenv\undefinedSymbol
- \expandafter\checkMdefinedValue\testMdef{\@tlabel@int{2}}%
- %% begin
- \specialFormEval{(\begin (\setB \mdefSymbol :1) 'hoge')}%
- \expandafter\Expect\expandafter{\spEvalResult}{\@tlabel@string{hoge}}%
- \expandafter\checkMdefinedValue\testMdef{\@tlabel@int{1}}%
- %% lambda
- \def\checkClosure#1#2#3#4#5{%
- \Expect{#1}{\@tlabel@closure}%
- \checkClosureValue#2{#3}{#4}{#5}}
- \def\checkClosureValue#1#2#3#4#5#6#7{%
- \Expect{#1}{#5}% bind
- \Expect{#2}{#6}% env
- \Expect{#3{#4}}{#7}% body
- }
- \specialFormEval{(\lambda (\x \y) :42)}%
- \expandafter\checkClosure\spEvalResult{\x\y:\@@unused}{}{\@tlabel@int{42}}%
- \specialFormEval{(\lambda (\x . \y) :42)}%
- \expandafter\checkClosure\spEvalResult{\x:\y}{}{\@tlabel@int{42}}%
- \specialFormEval{(\lambda \x :42)}%
- \expandafter\checkClosure\spEvalResult{:\x}{}{\@tlabel@int{42}}%
- %% @let
- \specialFormEval{(\@let \z 'foo' (\lambda (\x . \y) :42))}%
- \expandafter\checkClosure\spEvalResult{\x:\y}{\z{\@tlabel@string{foo}}}{\@tlabel@int{42}}%
- %% @mlet
- \def\checkClosureMutable#1#2#3#4#5{%
- \Expect{#1}{\@tlabel@closure}%
- \checkClosureValueMutable#2{#3}{#4}{#5}}
- \def\checkClosureValueMutable#1#2#3#4#5#6#7{%
- \Expect{#1}{#5}% bind
- \Expect{#3{#4}}{#7}% body
- \checkClosureEnvMutable#2#6}
- \def\checkClosureEnvMutable#1#2#3#4{%
- \Expect{#1}{#3} % bineded symbol
- \checkClosureEnvMutableInner#2{#4}}
- \def\checkClosureEnvMutableInner#1#2#3{%
- \Expect{#1}{\@tlabel@mutable}%
- \expandafter\Expect\expandafter{#2}{#3}}
- \specialFormEval{(\@mlet \z 'foo' (\lambda (\x . \y) :42))}%
- \expandafter\checkClosureMutable\spEvalResult{\x:\y}{\z{\@tlabel@string{foo}}}{\@tlabel@int{42}}%
- %% quote
- \specialFormEval{(\quote :42)}%
- \expandafter\Expect\expandafter{\spEvalResult}{\@tlabel@int{42}}%
- %% define
- \toks0\expandafter{\@globalenv}%
- \specialFormEval{(\define \x :42)}%
- \edef\hopedGlobalenv{\noexpand\x{\noexpand\@tlabel@int{42}}\the\toks0}%
- \expandafter\expandafter\expandafter\Expect\expandafter\expandafter\expandafter{\expandafter\@globalenv\expandafter}\expandafter{\hopedGlobalenv}%
- \expandafter\Expect\expandafter{\spEvalResult}{\@tlabel@nil{}}%
- %% defmacro
- \toks0\expandafter{\@globalenv}%
- \specialFormEval{(\defmacro \mac (\lambda (\c) \c))}% it is also used in macroexpand
- \edef\hopedGlobalenv{\noexpand\mac{\noexpand\@tlabel@macro{{\noexpand\c:\noexpand\@@unused}{}\noexpand\@tlabel@symbol{\noexpand\c}}}\the\toks0}%
- \expandafter\expandafter\expandafter\Expect\expandafter\expandafter\expandafter{\expandafter\@globalenv\expandafter}\expandafter{\hopedGlobalenv}%
- \expandafter\Expect\expandafter{\spEvalResult}{\@tlabel@nil{}}%
- %% macroexpand
- \def\testMacroExpand#1#2{%
- \Expect{#1}{\@tlabel@cons}%
- \testMacroExpandi#2}
- \def\testMacroExpandi#1#2{%
- \expandafter\Expect\expandafter{#1}{\@tlabel@symbol{\quote}}%
- \expandafter\testMacroExpandii#2}
- \def\testMacroExpandii#1#2{%
- \Expect{#1}{\@tlabel@cons}%
- \testMacroExpandiii#2}
- \def\testMacroExpandiii#1#2{%
- \expandafter\Expect\expandafter{#1}{\@tlabel@int{1}}%
- \expandafter\Expect\expandafter{#2}{\@tlabel@nil{}}}
- \specialFormEval{(\macroexpand (\quote (\mac (\quote :1))))}%
- \expandafter\testMacroExpand\spEvalResult
- \end{qstest}
- \begin{qstest}{one-shot continuation}{\@lispeval}
- \def\occEval#1{%
- \@lispread\parserTestCallBack#1%
- \setbox0=\hbox{\lispeval\parsedResult\occEvalResult}%
- \Expect*{\the\wd0}{0.0pt}}
- \occEval{(\callOCC (\lambda (\c) :1))}
- \expandafter\Expect\expandafter{\occEvalResult}{\@tlabel@int{1}}
- \occEval{(\callOCC (\lambda (\c) \c))}
- \expandafter\Expect\expandafter{\occEvalResult}{\@tlabel@continuation{1}}
- \occEval{(\callOCC (\lambda (\c) (\c :42)))}
- \expandafter\Expect\expandafter{\occEvalResult}{\@tlabel@int{42}}
- \occEval{(\callOCC (\lambda (\c) (\callOCC (\lambda (\d) \d))))}
- \expandafter\Expect\expandafter{\occEvalResult}{\@tlabel@continuation{2}}
- \end{qstest}
- \begin{qstest}{mutiple map}{\@lispeval}
- \def\occEval#1{%
- \@lispread\parserTestCallBack#1%
- \setbox0=\hbox{\lispeval\parsedResult\occEvalResult}%
- \Expect*{\the\wd0}{0.0pt}}
- \occEval{(\map (\lambda (\k) (\+ \k :1)) (\map (\lambda (\k) (\* \k :2)) (\quote (:1 :2))))}
-
- \end{qstest}
- \end{qstest}
- \LogClose{lgout}
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/asts.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/asts.tex
deleted file mode 100644
index 0baa79fd69f..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/asts.tex
+++ /dev/null
@@ -1,9 +0,0 @@
-\documentclass{article}
-\usepackage{expl3}
-\ExplSyntaxOn
-\cs_new:Npn \astsInner #1 {\prg_replicate:nn {#1} {*}}
-\ExplSyntaxOff
-\newcommand\astsExpliii[1]{\edef\asts{\astsInner{#1}}}
-\begin{document}
- \astsExpliii{10000}
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.pdf
deleted file mode 100644
index 2594f8edb14..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.tex
deleted file mode 100644
index 5a32abb8eda..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/mandel.tex
+++ /dev/null
@@ -1,79 +0,0 @@
-\documentclass{article}
-\usepackage[pdftex,a3paper,margin=1pt,landscape]{geometry}
-\usepackage{expl3}
-
-%% draw macros
-\newcount\mlength
-\mlength0
-\newcount\cstate
-\newdimen\mandelunit
-\mandelunit=0.5pt
-
-\def\wp{%
- \ifnum\cstate=1 \global\advance\mlength1
- \else\ifnum\cstate=-1 \vrule width \mlength\mandelunit height \mandelunit depth 0pt \global\mlength1 \fi\fi
- \global\cstate1}
-\def\bp{%
- \ifnum\cstate=-1 \global\advance\mlength1
- \else\ifnum\cstate=1 \hspace*{\mlength\mandelunit}\global\mlength1 \fi\fi
- \global\cstate-1}
-\def\r{%
- \ifnum\cstate=1\hspace*{\mlength\mandelunit}\else\vrule width \mlength\mandelunit height \mandelunit depth 0pt \fi
- \global\cstate0 \global\mlength0}
-
-\ExplSyntaxOn
- \int_const:Nn \l_hakviiaiii_maxloop {20}
- \fp_const:Nn \l_hakviiaiii_scale {0.002}
- \int_new:N \l_hakviiaiii_loopismandel
- \fp_new:N \l_hakviiaiii_x
- \fp_new:N \l_hakviiaiii_xx
- \fp_new:N \l_hakviiaiii_y
- \fp_new:N \l_hakviiaiii_yy
- \fp_new:N \l_hakviiaiii_a
- \fp_new:N \l_hakviiaiii_b
- \bool_new:N \l_hakviiaiii_check_mandel
- \cs_new:Npn \hakviiaiii_ismandel:nn #1#2{%
- \int_zero:N \l_hakviiaiii_loopismandel
- \fp_zero:N \l_hakviiaiii_x
- \fp_zero:N \l_hakviiaiii_y
- \fp_set:Nn \l_hakviiaiii_xx {\l_hakviiaiii_x * \l_hakviiaiii_x}%
- \fp_set:Nn \l_hakviiaiii_yy {\l_hakviiaiii_y * \l_hakviiaiii_y}%
- \bool_set_false:N\l_hakviiaiii_check_mandel
- \bool_while_do:nn {%
- \int_compare_p:nNn
- {\l_hakviiaiii_loopismandel}%
- < {\l_hakviiaiii_maxloop + 1}%
- && \fp_compare_p:nNn
- {\l_hakviiaiii_xx + \l_hakviiaiii_yy}< {4.0}%
- } {%
- \fp_set:Nn \l_hakviiaiii_y {%
- 2.0 * \l_hakviiaiii_x *\l_hakviiaiii_y + #2}%
- \fp_set:Nn \l_hakviiaiii_x {\l_hakviiaiii_xx - \l_hakviiaiii_yy + #1}%
- \fp_set:Nn \l_hakviiaiii_xx {\l_hakviiaiii_x * \l_hakviiaiii_x}%
- \fp_set:Nn \l_hakviiaiii_yy {\l_hakviiaiii_y * \l_hakviiaiii_y}%
- \int_set:Nn \l_hakviiaiii_loopismandel
- {\l_hakviiaiii_loopismandel + 1}%
- }%
- \bool_set:Nn \l_hakviiaiii_check_mandel
- {\int_compare_p:nNn
- {\l_hakviiaiii_loopismandel} > {\l_hakviiaiii_maxloop}}}
- \cs_new:Nn \hakviiaiii_loopmandel: {%
- \fp_set:Nn \l_hakviiaiii_b {1.0}%
- \fp_while_do:nNnn {\l_hakviiaiii_b} > {-1.0 - \l_hakviiaiii_scale} {%
- \fp_set:Nn \l_hakviiaiii_a {-1.5}%
- \fp_while_do:nNnn{\l_hakviiaiii_a} < {0.5 + \l_hakviiaiii_scale} {%
- \hakviiaiii_ismandel:nn{\l_hakviiaiii_a}{\l_hakviiaiii_b}%
- \bool_if:nTF
- {\l_hakviiaiii_check_mandel}%
- {\bp}{\wp}%
- \fp_set:Nn \l_hakviiaiii_a {\l_hakviiaiii_a + \l_hakviiaiii_scale}%
- } \r\\%
- \fp_set:Nn \l_hakviiaiii_b {\l_hakviiaiii_b - \l_hakviiaiii_scale}%
- }}
- \cs_new_eq:NN \mandel \hakviiaiii_loopmandel:
-\ExplSyntaxOff
-\begin{document}
- \thispagestyle{empty}\noindent
- \leavevmode\baselineskip=\mandelunit
- \mandel
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.pdf
deleted file mode 100644
index aa9b72aa3b2..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.tex
deleted file mode 100644
index ad61f174b4c..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/expl3/tarai.tex
+++ /dev/null
@@ -1,15 +0,0 @@
-\documentclass{article}
-\usepackage{expl3}
-\ExplSyntaxOn
-\cs_new:Npn \hakviiaiii_tarai:nnn #1#2#3 {%
- \int_compare:nTF{#1 <= #2}
- {#2}
- {\hakviiaiii_tarai:nnn
- {\hakviiaiii_tarai:nnn{\int_eval:n{#1 - 1}}{#2}{#3}}
- {\hakviiaiii_tarai:nnn{\int_eval:n{#2 - 1}}{#3}{#1}}
- {\hakviiaiii_tarai:nnn{\int_eval:n{#3 - 1}}{#1}{#2}}}}
-\cs_new_eq:NN \tarai \hakviiaiii_tarai:nnn
-\ExplSyntaxOff
-\begin{document}
- $\mathrm{Tarai}(14,12,10) = \tarai{14}{12}{10}$
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/ast.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/ast.tex
deleted file mode 100644
index 618a49f051b..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/ast.tex
+++ /dev/null
@@ -1,12 +0,0 @@
-\documentclass{article}
-\newcount\n
-\newcommand{\astsfast}[1]{%
-\n=#1
-\begingroup
-\aftergroup\edef\aftergroup\asts\aftergroup{%
-\loop \ifnum\n>0 \aftergroup*\advance\n-1
-\repeat
-\aftergroup}\endgroup}
-\begin{document}
- \astsfast{10000}
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.pdf
deleted file mode 100644
index 90245a28c72..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.tex
deleted file mode 100644
index 1166f3f9646..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/mandel.tex
+++ /dev/null
@@ -1,90 +0,0 @@
-\documentclass{article}
-\usepackage[pdftex,a3paper,margin=1pt,landscape]{geometry}
-%% draw macros
-\newcount\mlength
-\newcount\cstate
-\newdimen\mandelunit
-\mandelunit=0.5pt
-\def\wp{%
- \ifnum\cstate=1 \global\advance\mlength1
- \else\ifnum\cstate=-1 \vrule width \mlength\mandelunit height \mandelunit depth 0pt \global\mlength1 \fi\fi
- \global\cstate1}
-\def\bp{%
- \ifnum\cstate=-1 \global\advance\mlength1
- \else\ifnum\cstate=1 \hspace*{\mlength\mandelunit}\global\mlength1 \fi\fi
- \global\cstate-1}
-\def\r{%
- \ifnum\cstate=1\hspace*{\mlength\mandelunit}\else\vrule width \mlength\mandelunit height \mandelunit depth 0pt \fi
- \global\cstate0 \global\mlength0}
-
-% Mandelbrot
-\newskip\x
-\newskip\y
-\newskip\a
-\newskip\b
-\newskip\xx
-\newskip\yy
-\newskip\tmp
-\newcount\k
-\def\maxloop{20}
-\def\scale{0.002}
-
-\def\loopMandel{%
- \ifdim\b<-1.0pt\relax
- \let\next\relax
- \else
- \drawMandel
- \let\next\loopMandel
- \ifdim\a>0.5pt\relax
- \r\\
- \a=-1.5pt\relax
- \advance\b-\scale pt\relax
- \else
- \advance\a\scale pt\relax
- \fi
- \fi
- \next}
-\def\drawMandel{%
- \x=0pt\relax
- \y=0pt\relax
- \k=0\relax
- \checkMandel
- \ifnum\k>\maxloop\relax
- \bp
- \else
- \wp
- \fi
-}
-\makeatletter
-\def\checkMandel{%
- \ifnum\k>\maxloop
- \let\checkNext\relax
- \else
- \xx=\strip@pt\x\x
- \yy=\strip@pt\y\y
- \tmp\xx \advance\tmp\yy
- \ifdim\tmp>4.0pt\relax
- \let\checkNext\relax
- \else
- \let\checkNext\checkMandel
- \advance\k1\relax
- \tmp=\strip@pt\x\y
- \multiply\tmp2\relax
- \advance\tmp\b
- \y\tmp
- \x\a
- \advance\x\xx
- \advance\x-\yy
- \fi
- \fi
- \checkNext
-}
-\makeatother
-
-\begin{document}
-\thispagestyle{empty}\noindent
-\leavevmode\baselineskip=\mandelunit
-\a=-1.5pt\relax
-\b=1.0pt\relax
-\loopMandel
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.pdf
deleted file mode 100644
index 60898e3f228..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.tex
deleted file mode 100644
index 49cb281e53d..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/latex/tarai.tex
+++ /dev/null
@@ -1,27 +0,0 @@
-\documentclass{article}
-\newcount\d
-\def\tarai#1#2#3#4{%
- \begingroup
- \aftergroup\next
- \ifnum#1<#2%
- \gdef\next{\def#4{#2}}%
- \else\ifnum#1=#2%
- \gdef\next{\def#4{#2}}%
- \else
- \d#1%
- \advance\d-1
- \expandafter\tarai\expandafter{\the\d}{#2}{#3}\tx
- \d#2%
- \advance\d-1
- \expandafter\tarai\expandafter{\the\d}{#3}{#1}\ty
- \d#3%
- \advance\d-1
- \expandafter\tarai\expandafter{\the\d}{#1}{#2}\tz
- \xdef\next{\noexpand\tarai{\tx}{\ty}{\tz}\noexpand#4}%
- \fi\fi
- \endgroup}
-\begin{document}
- \tarai{14}{10}{6}\tmp
- $\mathrm{Tarai}(14,10,6) = \tmp$
-\end{document}
-
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.pdf
deleted file mode 100644
index d07e5497bfe..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.tex
deleted file mode 100644
index 1e5cdd2b3fb..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/asts.tex
+++ /dev/null
@@ -1,15 +0,0 @@
-\documentclass{article}
-\usepackage{lisp-on-tex}
-\lispinterp{
- (\define \foldl (\lambda (\func \init \list)
- (\lispif (\= \list ())
- \init
- (\foldl \func (\func \init (\car \list)) (\cdr \list)))))
- (\define \astsLoTInner (\lambda (\n \ret)
- (\lispif (\< :0 \n) (\astsLoTInner (\- \n :1) (\concat \ret '*'))
- \ret)))
- (\define \astsLoT (\lambda (\n) (\texprint (\concat '\def\asts' (\group (\astsLoTInner \n ''))))))
-}
-\begin{document}
-\lispinterp{(\astsLoT :10000)}
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.pdf
deleted file mode 100644
index fafec50f93e..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.tex
deleted file mode 100644
index 7aab7e1e8db..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/mandel.tex
+++ /dev/null
@@ -1,55 +0,0 @@
-\documentclass{article}
-\usepackage[pdftex,a3paper,margin=1pt,landscape]{geometry}
-\newcount\mlength
-\newcount\cstate
-\newdimen\mandelunit
-\mandelunit=0.5pt
-
-\def\w{%
- \ifnum\cstate=1 \global\advance\mlength1
- \else\ifnum\cstate=-1 \vrule width \mlength\mandelunit height \mandelunit depth 0pt \global\mlength1 \fi\fi
- \global\cstate1}
-\def\b{%
- \ifnum\cstate=-1 \global\advance\mlength1
- \else\ifnum\cstate=1 \hspace*{\mlength\mandelunit}\global\mlength1 \fi\fi
- \global\cstate-1}
-\def\r{%
- \ifnum\cstate=1\hspace*{\mlength\mandelunit}\else\vrule width \mlength\mandelunit height \mandelunit depth 0pt \fi
- \global\cstate0 \global\mlength0}
-
-\usepackage{lisp-on-tex}
-\usepackage{lisp-mod-fpnum}
-\lispinterp{%
- (\define \maxloop :20)
- (\define \scale +{fpnum::0.002})
- (\define \isMandell
- (\lambda (\a \b \k \x \y)
- (\lispif (\< \maxloop \k) /t
- (\lispif (\fplt +{fpnum::4.0} (\fpplus (\fpmul \x \x) (\fpmul \y \y)))
- /f
- (\isMandell \a \b (\+ \k :1)
- (\fpplus \a (\fpmul \x \x) (\fpminus (\fpmul \y \y)))
- (\fpplus \b (\fpmul +{fpnum::2.0} \x \y)))))))
- (\define \drawMandell (\lambda (\a \b)
- (\begin
- (\lispif (\isMandell \a \b :0 +{fpnum::0} +{fpnum::0})
- (\texprint '\b') (\texprint '\w'))
- (\immediatewrite))))
- (\define \loopMandell (\lambda (\a \b)
- (\lispif (\fplt \b +{fpnum::-1.0}) ()
- (\begin
- (\drawMandell \a \b)
- (\lispif (\fplt +{fpnum::0.5} \a)
- (\begin
- (\texprint '\r\\')
- (\immediatewrite)
- (\loopMandell +{fpnum::-1.5} (\fpminus \b \scale)))
- (\loopMandell (\fpplus \a \scale) \b))))))
-}
-
-\begin{document}
- \thispagestyle{empty}
- \noindent
- \leavevmode\baselineskip=\mandelunit
- \lispinterp{(\loopMandell +{fpnum::-1.5} +{fpnum::1.0})}
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.pdf
deleted file mode 100644
index 5f562c98116..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.tex
deleted file mode 100644
index f443187397f..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/lot/tarai.tex
+++ /dev/null
@@ -1,12 +0,0 @@
-\documentclass{article}
-\usepackage{lisp-on-tex}
-%\tracingmacros=1
-\lispinterp{
- (\define \tarai (\lambda (\x \y \z)
- (\lispif (\or (\< \x \y) (\= \x \y))
- \y
- (\tarai (\tarai (\- \x :1) \y \z) (\tarai (\- \y :1) \z \x) (\tarai (\- \z :1) \x \y)))))
-}
-\begin{document}
- $\mathrm{Tarai}(14,10,6) = \lispinterp{(\texprint (\tarai :14 :10 :6))}$
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.pdf
deleted file mode 100644
index d77b8459695..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.tex
deleted file mode 100644
index 2126d07b106..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/asts.tex
+++ /dev/null
@@ -1,15 +0,0 @@
-\documentclass{article}
-\usepackage[pdftex,a3paper,margin=1pt,landscape]{geometry}
-\newcommand\astsLua[1]{%
- \directlua{
- ret = ""
- for i=1,#1 do
- ret = ret .. "*"
- end
- tex.print("\noexpand\\def\noexpand\\asts{"..ret.."}")
- }
-}
-
-\begin{document}
- \astsLua{10000}
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.pdf
deleted file mode 100644
index f604a37d4a6..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.tex
deleted file mode 100644
index 2efa5d0ec7e..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/mandel.tex
+++ /dev/null
@@ -1,58 +0,0 @@
-\documentclass{article}
-\usepackage[pdftex,a3paper,margin=1pt,landscape]{geometry}
-%% draw macros
-\newcount\mlength
-\mlength0
-\newcount\cstate
-\newdimen\mandelunit
-\mandelunit=0.5pt
-
-
-\def\wp{%
- \ifnum\cstate=1 \global\advance\mlength1
- \else\ifnum\cstate=-1 \vrule width \mlength\mandelunit height \mandelunit depth 0pt \global\mlength1 \fi\fi
- \global\cstate1}
-\def\bp{%
- \ifnum\cstate=-1 \global\advance\mlength1
- \else\ifnum\cstate=1 \hspace*{\mlength\mandelunit}\global\mlength1 \fi\fi
- \global\cstate-1}
-\def\r{%
- \ifnum\cstate=1\hspace*{\mlength\mandelunit}\else\vrule width \mlength\mandelunit height \mandelunit depth 0pt \fi
- \global\cstate0 \global\mlength0}
-
-
-\begin{document}
- \thispagestyle{empty}\noindent
- \leavevmode\baselineskip=\mandelunit
- \directlua{
- maxloop=20
- scale=0.002
- function isMandel(a,b)
- x=0
- y=0
- xx=0
- yy=0
- for k=0,maxloop do
- xx=x*x
- yy=y*y
- if (xx + yy) > 4.0 then
- return false
- else
- y=2*x*y+b
- x=xx-yy+a
- end
- end
- return true
- end
- for b=1.0,-1.0,-scale do
- for a=-1.5,0.5,scale do
- if isMandel(a,b) then
- tex.print("\noexpand\\bp")
- else
- tex.print("\noexpand\\wp")
- end
- end
- tex.print("\noexpand\\r\noexpand\\\noexpand\\")
- end
- }
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.pdf
deleted file mode 100644
index a4c5ddd3f0f..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.tex
deleted file mode 100644
index e4a51f711ee..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.tex
+++ /dev/null
@@ -1,14 +0,0 @@
-\documentclass{article}
-\directlua{
- function tarai(x,y,z)
- if(x<=y) then
- return y
- else
- return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
- end
- end
-}
-\newcommand\tarai[3]{\directlua{tex.print(tarai(#1, #2, #3))}}
-\begin{document}
-$\mathrm{Tarai}(14,10,6) = \tarai{14}{10}{6}$
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.pdf
deleted file mode 100644
index d36057e5eb5..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.tex
deleted file mode 100644
index 5b0aebdf708..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/ast.tex
+++ /dev/null
@@ -1,7 +0,0 @@
-\documentclass{article}
-\usepackage{perltex}
-\newcommand{\asts}{}
-\perlnewcommand{\astsperl}[1]{'\renewcommand{\asts}{'. '*' x $_[0] . '}'}
-\begin{document}
- \astsperl{10000}\asts
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.pdf
deleted file mode 100644
index c4713aa121a..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.tex
deleted file mode 100644
index f197297135e..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/mandel.tex
+++ /dev/null
@@ -1,64 +0,0 @@
-\documentclass{article}
-\usepackage[pdftex,a3paper,margin=1pt,landscape]{geometry}
-\usepackage{perltex}
-\newcount\mlength
-\newcount\cstate
-\newdimen\mandelunit
-\mandelunit=0.5pt
-
-\def\w{%
- \ifnum\cstate=1 \global\advance\mlength1
- \else\ifnum\cstate=-1 \vrule width \mlength\mandelunit height \mandelunit depth 0pt \global\mlength1 \fi\fi
- \global\cstate1}
-\def\b{%
- \ifnum\cstate=-1 \global\advance\mlength1
- \else\ifnum\cstate=1 \hspace*{\mlength\mandelunit}\global\mlength1 \fi\fi
- \global\cstate-1}
-\def\r{%
- \ifnum\cstate=1\hspace*{\mlength\mandelunit}\else\vrule width \mlength\mandelunit height \mandelunit depth 0pt \fi
- \global\cstate0 \global\mlength0}
-
-\perlnewcommand{\isMandel}[2]{
- my $maxloop=20;
- my $x = 0;
- my $y = 0;
- my $xx = 0;
- my $yy = 0;
- for(my $k=0; $k<=$maxloop; $k++){
- $xx = $x ** 2;
- $yy = $y ** 2;
- if($xx + $yy > 4.0) { return 0; }
- $y = 2*$x*$y + $_[1];
- $x = $xx - $yy + $_[0];
- }
- return 1;
-}
-\perlnewcommand{\loopMandel}{
- my $scale=0.002;
- my $ret = "";
- for(my $b=1.0; $b >=-1.0; $b-=$scale){
- $ret = $ret . "\\loopMandelInner{" . $b . "}\\r\\\\";
- }
- return $ret;
-}
-\perlnewcommand{\loopMandelInner}[1]{
- my $scale=0.002;
- my $ret = "";
- my $b = $_[0];
- for(my $a=-1.5; $a<=0.5; $a+=$scale){
- if(latex_isMandel($a, $b)){
- $ret .= "\\b";
- } else {
- $ret .= "\\w";
- }
- }
- return $ret;
-}
-
-
-\begin{document}
- \thispagestyle{empty}
- \noindent
- \leavevmode\baselineskip=\mandelunit
- \loopMandel
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.pdf
deleted file mode 100644
index 22b8504926e..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.tex
deleted file mode 100644
index 7ee739bbb9d..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/perltex/tarai.tex
+++ /dev/null
@@ -1,15 +0,0 @@
-\documentclass{article}
-\usepackage{perltex}
-\perlnewcommand{\tarai}[3]{
- if($_[0] <= $_[1]){
- return $_[1];
- } else {
- return latex_tarai(
- latex_tarai($_[0]-1, $_[1], $_[2]),
- latex_tarai($_[1]-1, $_[2], $_[0]),
- latex_tarai($_[2]-1, $_[0], $_[1]));
- }
-}
-\begin{document}
- $\mathrm{Tarai}(14,10,6) = \tarai{14}{10}{6}$
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/slide.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/slide.tex
deleted file mode 100644
index 5a46c31348e..00000000000
--- a/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/slide.tex
+++ /dev/null
@@ -1,213 +0,0 @@
-\documentclass[pdftex,10pt,c,compress]{beamer}
-%Settings for LaTeX beamer
-\usetheme{Berkeley}
-\usecolortheme{orchid}
-\setbeamertemplate{navigation symbols}{}
-
-%Font Info
-\usepackage[T1]{fontenc}
-\renewcommand{\sfdefault}{phv}
-\renewcommand{\ttdefault}{pcr}
-% Font Info(pLaTeX only)
-%\renewcommand{\kanjifamilydefault}{\gtdefault}
-
-%packages
-\usepackage{url}
-\usepackage{lisp-on-tex}
-
-%colors
-\definecolor{orderzero}{HTML}{04BBFF}
-\definecolor{orderi}{HTML}{03A8E5}
-\definecolor{orderii}{HTML}{038CBF}
-\definecolor{orderiii}{HTML}{025E7F}
-\definecolor{orderover}{HTML}{012F40}
-
-\lispinterp{
- (\define \fact (\lambda (\n)
- (\lispif (\= \n :0) :1
- (\* (\fact (\- \n :1)) \n))))
-}
-
-%Document Info
-\title{LISP on \TeX}
-\subtitle{A LISP Interpreter Written Using \TeX{} Macros}
-\author[S. HAKUTA]{HAKUTA Shizuya}
-\date[TUG2013]{The 34th Annual Meeting of the TeX Users Group, 2013}
-
-\begin{document}
- \frame{\titlepage}
-
- \section{Introduction}
-
- \begin{frame}{Background}
- \begin{itemize}
- \item Writing \TeX{} macros is useful.
- \begin{itemize}
- \item e.g. Calculating some small numeric expressions.
- \end{itemize}
- \item However, it is difficult for novice users.
- \vspace{1cm}
- \item To improve, there are some researches that combine
- \TeX{} and another programming language.
- \end{itemize}
- \end{frame}
-
- \begin{frame}{\TeX{} with Other Languages}
- Pakin[TUGboat '03] showed four way to connect \TeX{}
- and a foreign programing language;
- \begin{enumerate}
- \item using \texttt{\string\write18} to call an outer processor,
- \begin{itemize}
- \item python package (CTAN:macros/latex/contrib/python)
- \end{itemize}
- \item embedding an interpreter in a \TeX{} engine,
- \begin{itemize}
- \item Lua\TeX{} (CTAN:systems/luatex)
- \end{itemize}
- \item constructing macros that enable \LaTeX{} to communicate
- with an external interpreter,
- \begin{itemize}
- \item Perl\TeX{} (CTAN:macros/latex/conrtib/perltex)
- \end{itemize}
- \item creating a language processor with \TeX{} macros
- \begin{itemize}
- \item \LaTeX3 project created expl3: a new interface of \TeX{} macros,
- but {\color{red}no ordinary language was implemented}.
- \end{itemize}
- \end{enumerate}
- \end{frame}
-
- \section{Goal and Mean}
- \begin{frame}{The Goal and the Mean}
- Our goals are
- \begin{itemize}
- \item Implementing a language's interpreter with \TeX{} macros, and
- \item Comparing its performance with other approaches.
- \end{itemize}
- \vspace{0.5cm}
- We take two design choices;
- \begin{enumerate}
- \item Choosing LISP as a ordinary language, and
- \item Creating the product as a LaTeX package.
- \end{enumerate}
- \end{frame}
-
- \section{LISP on TeX}
- \begin{frame}{LISP on \TeX}
- We name the our product {\color{red} LISP on \TeX{}}.
- \begin{itemize}
- \item It was already archived on CTAN and \TeX Live.
- \begin{itemize}
- \item \url{macros/latex/contrib/lisp-on-tex}
- \end{itemize}
- \item We constructed all parts of LISP on \TeX{} with \TeX{} macros;
- \begin{itemize}
- \item parser, recognizing LISP expressions,
- \item evaluator, calculating a expression, and
- \item environment, mapping symbols to LISP objects.
- \end{itemize}
- \item The code is written with traditional TeX macros only,
- so it works in all \LaTeX{} engines,
- \begin{itemize}
- \item \LaTeX, pdf\LaTeX, Lua\LaTeX, Xe\LaTeX, p\LaTeX, \dots
- \end{itemize}
- \end{itemize}
- \end{frame}
-
-
- \begin{frame}[t, fragile]{Examples (1/2)}
- \structure{Source}
- \begin{footnotesize}
- \begin{block}{The Preamble of the Slides}\vspace{-\baselineskip}
-\begin{semiverbatim}
-\\usepackage\{lisp-on-tex\}
-
-\\lispinterp\{
- (\\define \\fact
- (\\lambda (\\n)
- (\\lispif (\\= \\n :0) :1
- (\\* (\\fact (\\- \\n :1)) \\n))))\}
-\end{semiverbatim}\vspace{-\baselineskip}
- \end{block}
- \end{footnotesize}
- \structure{Result}\mbox{}\\
- \strut\alt<2->{$10!=\lispinterp{(\texprint (\fact :10))}$}%
- {\footnotesize
- \texttt{\$10!=\string\lispinterp\{(\string\texprint (\string
- \fact :10))\}\$}}
- \begin{center}\color{red}\Large
- \onslide<3->{LISP codes were evaluated!}
- \end{center}
-\end{frame}
-
- \begin{frame}{Examples (2/2)}
- \begin{center}
- \alt<2>{\includegraphics[scale=0.38]{dest_mandel.png}}
- {\includegraphics[scale=0.3]{source_mandel.png}}
- \end{center}
- \end{frame}
-
-
- \begin{frame}{Memory Management Problems}
- \begin{itemize}
- \item LISP on \TeX{} uses a lot of memory.
- \begin{itemize}
- \item Yato showed that LISP on \TeX{} stalls
- when using a lot of LISP objects\footnote{%
- \url{http://d.hatena.ne.jp/zrbabbler/20121116/1353068217} (Japanese Only)}.
- \end{itemize}
- \item It is caused by spending a lot of control sequences.
- \item Building a garbage collection system is one of our future work.
- \end{itemize}
- \end{frame}
-
-
- \section{Comparison}
- \begin{frame}{Comparison to other approaches}
- We compared LISP on \TeX{} and other approaches
- by three benchmarks.
- \begin{itemize}
- \item CPU Core i7 2.2GHz, 8GByte Memory, W32TeX
- \end{itemize}
- \begin{center}
- \begin{tabular}{|c||c|c|c|}\hline
- & tarai[sec] & asterisks[sec] & Mandelbrot[sec] \\ \hline\hline
- LISP on \TeX & 13 & $1.6 \times 10^2$ & $2.1 \times 10^4$\\ \hline
- Perl\TeX & 1.0 & 1.0 & $1.6 \times 10^2$ \\ \hline
- Lua\TeX & 0.45 & 0.55 & 7.6 \\ \hline
- \TeX{} macros & 0.24 & 0.22 & $1.2 \times 10^2$ \\ \hline
- expl3 & 1.1 & 1.0 & $5.7 \times 10^3$\\ \hline
- \end{tabular}
- \end{center}
- \begin{itemize}
- \item It shows that LISP on \TeX{} is too slow... :-(
- \begin{itemize}
- \item It is caused by reading \TeX{} tokens repeatedly.
- \item[$\Rightarrow$] We can make LISP on \TeX{} faster
- with improving the code.
- \end{itemize}
- \end{itemize}
- \end{frame}
-
-
- \section{Conclusion}
- \begin{frame}{Conclusion}
- \begin{itemize}
- \item We implemented LISP on \TeX{}, a LISP interpreter
- written only with \TeX{} macros.
- \item It works well, but the product has
- problems about memory usage and speed.
- \end{itemize}
- \end{frame}
-
- \begin{frame}{Why LISP is Selected?}
- There are two reasons why we select LISP.
- \begin{enumerate}
- \item LISP is Turing complete, so it contains all essence of
- programming languages.
- \item Because LISP has simple syntax and semantics, we can
- implement LISP easily.
- \end{enumerate}
- \end{frame}
-
-\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty
index 23d48402873..1e4f622dbe1 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty
@@ -1,6 +1,7 @@
\newcount\@temp@inti
\newcount\@temp@intii
-\addassoc\@globalenv\+{\@tlabel@func{\@temp@inti0\relax\@arith@plus}}
+
+\@lisp@env@add@global\+{\@tlabel@func{\@lisp@func@check@args{*}{\@temp@inti0\relax\@arith@plus}}}
\def\@arith@plus#1#2#3{%
\ifx#2\relax
\let\@next@plus\@@arith@pm@fin
@@ -8,23 +9,30 @@
\advance\@temp@inti#3\relax
\let\@next@plus\@arith@plus
\else
- \errmessage{LISP on TeX [integer plus]: Invalid argument}%
+ \let\@next@plus\@arith@type@error
\fi\fi\@next@plus#1}
-\addassoc\@globalenv\*{\@tlabel@func{\@temp@inti1\relax\@arith@mul}}
+\@lisp@env@add@global\*{\@tlabel@func{\@lisp@func@check@args{*}{\@temp@inti1\relax\@arith@mul}}}
\def\@arith@mul#1#2#3{%
\ifx#2\relax
\let\@next@mul\@@arith@pm@fin
\else\ifx#2\@tlabel@int
\multiply\@temp@inti#3\relax
\let\@next@mul\@arith@mul
+ \else
+ \let\@next@mul\@arith@type@error
\fi\fi\@next@mul#1}
\def\@@arith@pm@fin#1{\expandafter\gdef
\expandafter#1\expandafter{%
\expandafter\@tlabel@int\expandafter{\the\@temp@inti}}}
-\addassoc\@globalenv\-{\@tlabel@func{\@arith@minus}}
+\def\@arith@type@error#1#2\relax{% notice #2 is dust
+ \gdef#1{\@tlabel@exception{{-1}%
+ {\@tlabel@string{arithmetical functions takes integer only.}}}}}
+
+\@lisp@env@add@global\-{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@minus}}}
+%TODO: error handling of 1st argument
\def\@arith@minus#1#2#3#4#5{%
\@temp@inti#3\relax
\ifx#4\relax
@@ -32,6 +40,8 @@
\let\@next@minus\@@arith@pm@fin
\else\ifx#4\@tlabel@int
\let\@next@minus\@@arith@minus
+ \else
+ \let\@next@minus\@arith@type@error
\fi\fi\@next@minus#1#4{#5}}
\def\@@arith@minus#1#2#3{%
@@ -41,10 +51,13 @@
\@temp@intii#3\relax % #3 < 0
\advance\@temp@inti-\@temp@intii\relax
\let\@next@minus\@@arith@minus
+ \else
+ \let\@next@minus\@arith@type@error
\fi\fi\@next@minus#1}
-\addassoc\@globalenv\/{\@tlabel@func{\@arith@div}}
+\@lisp@env@add@global\/{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@div}}}
+%TODO: error handling of 1st argument
\def\@arith@div#1#2#3#4#5{%
\@temp@inti#3\relax
\ifx#4\relax
@@ -54,6 +67,8 @@
\let\@next@div\@@arith@pm@fin
\else\ifx#4\@tlabel@int
\let\@next@div\@@arith@div
+ \else
+ \let\@next@div\@arith@type@error
\fi\fi\@next@div#1#4{#5}}
\def\@@arith@div#1#2#3{%
@@ -62,9 +77,12 @@
\else\ifx#2\@tlabel@int
\divide\@temp@inti#3\relax
\let\@next@div\@@arith@div
+ \else
+ \let\@next@div\@arith@type@error
\fi\fi\@next@div#1}
-\addassoc\@globalenv\mod{\@tlabel@func{\@arith@mod}}
+\@lisp@env@add@global\mod{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@mod}}}
+%TODO: error handling
\def\@arith@mod#1\@tlabel@int#2\@tlabel@int#3{%
\@temp@intii#2\relax
\divide\@temp@intii#3\relax
@@ -73,43 +91,50 @@
\advance\@temp@inti-\@temp@intii
\@@arith@pm@fin#1}
-\addassoc\@globalenv\<{\@tlabel@func{\@arith@lt}}
+\@lisp@env@add@global\<{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@lt}}}
+%TODO: error handling
\def\@arith@lt#1\@tlabel@int#2\@tlabel@int#3{%
\ifnum#2<#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi}
-\addassoc\@globalenv\>{\@tlabel@func{\@arith@gt}}
+\@lisp@env@add@global\>{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@gt}}}
+%TODO: error handling
\def\@arith@gt#1\@tlabel@int#2\@tlabel@int#3{%
\ifnum#2>#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi}
-\addassoc\@globalenv\leq{\@tlabel@func{\@arith@leq}}
+\@lisp@env@add@global\leq{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@leq}}}
+%TODO: error handling
\def\@arith@leq#1\@tlabel@int#2\@tlabel@int#3{%
\ifnum#2<#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi
\ifnum#2=#3 \gdef#1{\@tlabel@bool{t}}\fi}
-\addassoc\@globalenv\geq{\@tlabel@func{\@arith@geq}}
+\@lisp@env@add@global\geq{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@geq}}}
+%TODO: error handling
\def\@arith@geq#1\@tlabel@int#2\@tlabel@int#3{%
\ifnum#2>#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi
\ifnum#2=#3 \gdef#1{\@tlabel@bool{t}}\fi}
-\addassoc\@globalenv\isZeroQ{\@tlabel@func{\@arith@is@zero}}
+\@lisp@env@add@global\isZeroQ{\@tlabel@func{\@lisp@func@check@args{1}{\@arith@is@zero}}}
+%TODO: error handling
\def\@arith@is@zero#1\@tlabel@int#2{%
\ifnum#2=0 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi}
-\addassoc\@globalenv\positiveQ{\@tlabel@func{\@arith@is@positive}}
+\@lisp@env@add@global\positiveQ{\@tlabel@func{\@lisp@func@check@args{1}{\@arith@is@positive}}}
+%TODO: error handling
\def\@arith@is@positive#1\@tlabel@int#2{%
\ifnum#2>0 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi}
-\addassoc\@globalenv\negativeQ{\@tlabel@func{\@arith@is@negative}}
-\def\@arith@is@positive#1\@tlabel@int#2{%
+\@lisp@env@add@global\negativeQ{\@tlabel@func{\@lisp@func@check@args{1}{\@arith@is@negative}}}
+%TODO: error handling
+\def\@arith@is@negative#1\@tlabel@int#2{%
\ifnum#2<0 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi}
-\addassoc\@globalenv\max{\@tlabel@func{\@arith@max}}
+\@lisp@env@add@global\max{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@max}}}
\def\@arith@max#1#2#3{%
\ifx#2\@tlabel@int
\@temp@inti#3\relax
\let\@next@max\@@arith@max
\else
- \errmessage{LISP on TeX [integer max]: Invalid argument or Too few arguments}%
+ \let\@next@max\@arith@type@error
\fi\@next@max#1}
\def\@@arith@max#1#2#3{%
\ifx#2\relax
@@ -118,16 +143,16 @@
\ifnum#3>\@temp@inti\@temp@inti#3\relax\fi
\let\@next@max\@@arith@max
\else
- \errmessage{LISP on TeX [integer max]: Invalid argument}%
+ \let\@next@max\@arith@type@error
\fi\fi\@next@max#1}
-\addassoc\@globalenv\min{\@tlabel@func{\@arith@min}}
+\@lisp@env@add@global\min{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@min}}}
\def\@arith@min#1#2#3{%
\ifx#2\@tlabel@int
\@temp@inti#3\relax
\let\@next@min\@@arith@min
\else
- \errmessage{LISP on TeX [integer min]: Invalid argument or Too few arguments}%
+ \let\@next@min\@arith@type@error
\fi\@next@min#1}
\def\@@arith@min#1#2#3{%
\ifx#2\relax
@@ -136,5 +161,5 @@
\ifnum#3<\@temp@inti\@temp@inti#3\relax\fi
\let\@next@min\@@arith@min
\else
- \errmessage{LISP on TeX [integer min]: Invalid argument}%
+ \let\@next@min\@arith@type@error
\fi\fi\@next@min#1}
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-cast.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-cast.sty
deleted file mode 100644
index a6e62573961..00000000000
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-cast.sty
+++ /dev/null
@@ -1,3 +0,0 @@
-% LISP on TeX type cast
-
-% string
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-gc.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-gc.sty
new file mode 100644
index 00000000000..672593c0376
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-gc.sty
@@ -0,0 +1,197 @@
+\RequirePackage{xkeyval}
+
+\newcount\@lisp@gc@count
+\newcount\@lisp@gc@perform@result
+\def\@lisp@gc@alloc@count@max{32768} % memory limit
+\def\@lisp@gc@alloc@local{} % objects on stack
+\def\@lisp@gc@usedenv{} % used local environment
+\def\@lisp@gc@alloc@raw{} % used memory on local
+\def\@lisp@gc@alloc@pinning{} % pinned objects
+\def\@lisp@gc@mark@bitvector{} % mark bitmap
+\def\@lisp@gc@mark@bitvector@{} % mark bitmap (default)
+
+% execute GC option
+\DeclareOptionX{heapsize}{\def\@lisp@gc@alloc@count@max{#1}}
+\ProcessOptionsX
+
+% gc initializer (called by lisp-on-tex.sty)
+\def\@lisp@gc@init{%
+ \@lisp@gc@count=0\relax
+ \@lisp@gc@perform@result=\@lisp@gc@alloc@count@max\relax
+ % create mark bits
+ % clear all mark bits
+ \@tempcnta0
+ \@whilenum\@tempcnta<\@lisp@gc@alloc@count@max\do{%
+ \@lisp@gc@off@markbit{\the\@tempcnta}%
+ \advance\@tempcnta1}%
+ % set default value to each memory
+ \@tempcnta0
+ \@whilenum\@tempcnta<\@lisp@gc@alloc@count@max\do{%
+ \expandafter\gdef
+ \csname @lisp@gc@memory@\the\@tempcnta\endcsname
+ {\relax\relax}% initialize
+ \advance\@tempcnta1}}
+
+% allocator
+% The allocator define #1 to allocated the control sequence
+\def\@lisp@gc@alloc#1{%
+ % if memory is full, do gc
+ \ifnum\@lisp@gc@count<\@lisp@gc@alloc@count@max\else
+ \@lisp@gc@perform
+ \fi
+ % allocation
+ \def#1{}%
+ \@lisp@gc@alloc@@#1}
+\def\@lisp@gc@alloc@@#1{%
+ \csname if@lisp@gc@memory@\the\@lisp@gc@count\endcsname
+ \else % unused memory is found
+ % allocate
+ \expandafter\def\expandafter#1%
+ \expandafter{\csname @lisp@gc@memory@\the\@lisp@gc@count\endcsname}%
+ % clear memory (for marking)
+ \expandafter\gdef
+ \csname @lisp@gc@memory@\the\@lisp@gc@count\endcsname{\relax\relax}%
+ \fi
+ \global\advance\@lisp@gc@count1
+ \let\@@next\@gobble
+ \ifx#1\@empty
+ \ifnum\@lisp@gc@count<\@lisp@gc@alloc@count@max
+ \let\@@next\@lisp@gc@alloc@@
+ \else
+ \def\@@next{%
+ \@lisp@gc@perform
+ \ifnum\@lisp@gc@perform@result=0\relax
+ \expandafter\@gobble % empty
+ \else
+ \expandafter\@lisp@gc@alloc@@
+ \fi}%
+ \fi
+ \fi
+ \@@next#1}
+
+
+% GC main routine. The routine is called by the allocator.
+% If you want to call GC manually, you can do it.
+\def\@lisp@gc@perform{%
+ \message{LISP on TeX: now GCing...^^J}%
+ % reset result
+ \global\@lisp@gc@perform@result\@lisp@gc@alloc@count@max\relax
+ % clear all mark bits
+ \@tempcnta0
+ \@whilenum\@tempcnta<\@lisp@gc@count\do{%
+ \@lisp@gc@off@markbit{\the\@tempcnta}%
+ \advance\@tempcnta1}%
+ % start marking mode
+ \begingroup
+ % define all typelabels to mark mode
+ \@lisp@gc@make@tlabel@mark@mode
+ % init queue and enque root set
+ %% raw memory
+ \expandafter\def\expandafter\@lisp@gc@mark@Q\expandafter{\@lisp@gc@alloc@raw}%
+ %% local env
+ \expandafter\@lisp@gc@mark@env\@lisp@gc@usedenv\@lisp@unused\relax
+ %% global env
+ \expandafter\@lisp@gc@mark@env\@lisp@globalenv\@lisp@unused\relax
+ %% pinned objects
+ \@lisp@gc@alloc@pinning
+ %% stack
+ \@lisp@gc@alloc@local
+ % marking start
+ \@lisp@gc@foreachQ\@lisp@gc@mark@Q\@lisp@gc@mark
+ % end marking mode
+ \endgroup
+ % reset counter
+ \global\@lisp@gc@count0
+ % show GC result
+ \message{LISP on TeX: GC done (free \the\@lisp@gc@perform@result)^^J}}
+\def\@lisp@gc@make@tlabel@mark@mode{%
+ \@for\@lisp@on@tex@type:=\@defined@lisp@on@tex\do{%
+ \expandafter\let
+ \csname @tlabel@\@lisp@on@tex@type\endcsname\@gobble}%
+ \def\@tlabel@cons##1{\@lisp@gc@mark@cons##1}%
+ \def\@tlabel@mutable##1{\@lisp@gc@enQ\@lisp@gc@mark@Q{##1}}%
+ \def\@tlabel@closure##1{\@lisp@gc@mark@closure##1}%
+ \def\@tlabel@macro##1{\@lisp@gc@mark@closure##1}%
+ \def\@tlabel@exception##1{\@lisp@gc@mark@exception##1}%
+ \@for\@lisp@on@tex@type:=\@defined@additional@type\do{%
+ \expandafter\@lisp@gc@create@markmode@additional
+ \csname @tlabel@\@lisp@on@tex@type\endcsname
+ \csname @lisp@gc@trace\@lisp@on@tex@type\endcsname}}
+\def\@lisp@unused{\@lisp@unused@}
+\def\@lisp@gc@mark@cons#1#2{%
+ \@lisp@gc@enQ\@lisp@gc@mark@Q{#1}%
+ \@lisp@gc@enQ\@lisp@gc@mark@Q{#2}}
+\def\@lisp@gc@mark@closure#1#2#3#4{%
+ \@lisp@gc@mark@env#2\@lisp@unused\relax
+ #3{#4}}
+\def\@lisp@gc@mark@exception#1#2{#2}%
+\def\@lisp@gc@create@markmode@additional#1{%
+ \expandafter\@lisp@gc@create@markmode@additional@\expandafter#1}
+\def\@lisp@gc@create@markmode@additional@#1#2{\let#1#2}
+% mark objects in a environment
+\def\@lisp@gc@mark@env#1#2{%
+ \ifx#1\@lisp@unused
+ \let\@@next\relax
+ \else
+ \def\@@next{#2\@lisp@gc@mark@env}%
+ \fi
+ \@@next}
+% global let for save and restore memory
+\def\@lisp@gc@global@let#1{\expandafter\@lisp@gc@global@let@\expandafter#1}
+\def\@lisp@gc@global@let@#1#2{\global\let#1#2}
+% queue
+\def\@lisp@gc@enQ#1#2{% #1 : queue, #2 value
+ \expandafter\def\expandafter#1\expandafter{#1#2}}
+\def\@lisp@gc@deQ#1#2{% #1 : queue, #2 cs
+ \ifx#1\@empty
+ \def#2{}%
+ \else
+ \expandafter\@lisp@gc@deQ@\expandafter#1\expandafter#2#1\relax
+ \fi}
+\def\@lisp@gc@deQ@#1#2#3#4\relax{%
+ \def#1{#4}\def#2{#3}}
+\def\@lisp@gc@foreachQ#1#2{% #1 : queue, #2 : token -> 'a
+ \@lisp@gc@deQ#1\@lisp@gc@temp@local
+ \ifx\@lisp@gc@temp@local\@empty
+ \let\@@next\relax
+ \else
+ \def\@@next{%
+ \expandafter#2\expandafter{\@lisp@gc@temp@local}%
+ \@lisp@gc@foreachQ#1#2}%
+ \fi\@@next}
+% marker
+\def\@lisp@gc@mark#1{\expandafter\@lisp@gc@mark@\string#1\relax}
+\expandafter\def\expandafter\@lisp@gc@mark@\string\@lisp@gc@memory@#1\relax{%
+ \csname if@lisp@gc@memory@#1\endcsname\else
+ % count down remain memory
+ \global\advance\@lisp@gc@perform@result-1
+ % turn mark bit on
+ \@lisp@gc@on@markbit{#1}%
+ % enqueue if we need
+ \csname @lisp@gc@memory@#1\endcsname
+ \fi}
+
+
+% pin a object on global.
+\def\@lisp@gc@pinning#1#2{%
+ \expandafter\gdef\expandafter\@lisp@gc@alloc@pinning
+ \expandafter{\@lisp@gc@alloc@pinning#1{#2}}}
+
+% pinning objects on local.
+\def\@lisp@gc@save@objects@local#1{%
+ \expandafter\def\expandafter\@lisp@gc@alloc@local
+ \expandafter{\@lisp@gc@alloc@local#1}}
+
+% pinning memories on local.
+\def\@lisp@gc@save@memory@local#1{%
+ \expandafter\def\expandafter\@lisp@gc@alloc@raw
+ \expandafter{\@lisp@gc@alloc@raw#1}}
+
+% pinning environmnt on local.
+\def\@lisp@gc@save@env@local#1{%
+ \expandafter\def\expandafter\@lisp@gc@usedenv
+ \expandafter{\@lisp@gc@usedenv#1}}
+
+% for mark bits
+\def\@lisp@gc@on@markbit#1{\expandafter\global\expandafter\let\csname if@lisp@gc@memory@#1\endcsname\iftrue}
+\def\@lisp@gc@off@markbit#1{\expandafter\global\expandafter\let\csname if@lisp@gc@memory@#1\endcsname\iffalse} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-latexutil.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-latexutil.sty
index 633e5cd13d5..58c612bb087 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-latexutil.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-latexutil.sty
@@ -1,7 +1,8 @@
%% READ_LaTeX_Counter : string -> int
%% (\readLaTeXCounter str) -> i
%% where i = \the\c@str
-\addassoc\@globalenv\readLaTeXCounter{\@tlabel@func{\@tex@read@latex@counter}}
+\@lisp@env@add@global\readLaTeXCounter{\@tlabel@func{\@lisp@func@check@args{1}{\@tex@read@latex@counter}}}
+%TODO: error handling
\def\@tex@read@latex@counter#1#2#3{%
\expandafter\expandafter\expandafter\gdef
\expandafter\expandafter\expandafter#1%
@@ -10,6 +11,7 @@
\expandafter\expandafter\expandafter{%
\expandafter\the\csname c@#3\endcsname}}}
-\addassoc\@globalenv\message{\@tlabel@func{\@tex@lisp@message}}
+\@lisp@env@add@global\message{\@tlabel@func{\@lisp@func@check@args{1}{\@tex@lisp@message}}}
+%TODO: error handling
\def\@tex@lisp@message#1\@tlabel@string#2{%
- \gdef#1{\@tlabel@nil{}}\message{^^J#2^^J}} \ No newline at end of file
+ \gdef#1{\@tlabel@nil{}}\message{#2}} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-fpnum.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-fpnum.sty
index 54af9aa33dd..291b343baa3 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-fpnum.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-fpnum.sty
@@ -1,5 +1,13 @@
%%% module name :: fpnum
+% regist type and gc
+\ifx\@defined@additional@type\@empty
+ \def\@defined@additional@type{fpnum}%
+\else
+ \edef\@defined@additional@type{\@defined@additional@type,fpnum}%
+\fi
+\let\@lisp@gc@trace@fpnum\@gobble
+
\def\@mod@read@fpnum#1#2{\gdef#1{\@tlabel@fpnum{#2}}}
\def\@tlabel@fpnum{\@eval@fpnum\@apply@fpnum\@@apply@fpnum}
@@ -10,10 +18,12 @@
\newdimen\@tempdimeni
\newdimen\@tempdimenii
-\addassoc\@globalenv\fpnumTOstring{\@tlabel@func{\@mod@fpnum@tostring}}
+\@lisp@env@add@global\fpnumTOstring{\@tlabel@func{\@lisp@func@check@args{1}{\@mod@fpnum@tostring}}}
+%TODO: error handling
\def\@mod@fpnum@tostring#1\@tlabel@fpnum#2{\gdef#1{\@tlabel@string{#2}}}
-\addassoc\@globalenv\fpplus{\@tlabel@func{\@tempdimeni0pt\relax\@mod@fpnum@plus}}
+\@lisp@env@add@global\fpplus{\@tlabel@func{\@lisp@func@check@args{*}{\@tempdimeni0pt\relax\@mod@fpnum@plus}}}
+%TODO: error handling
\def\@mod@fpnum@plus#1#2#3{%
\ifx#2\relax
\let\@next@fpnum@plus\@@fin@fpnum@plus
@@ -25,7 +35,8 @@
\fi\fi\@next@fpnum@plus#1}
\def\@@fin@fpnum@plus#1{\xdef#1{\noexpand\@tlabel@fpnum{\strip@pt\@tempdimeni}}}
-\addassoc\@globalenv\fpmul{\@tlabel@func{\@tempdimeni1pt\relax\@mod@fpnum@mul}}
+\@lisp@env@add@global\fpmul{\@tlabel@func{\@lisp@func@check@args{*}{\@tempdimeni1pt\relax\@mod@fpnum@mul}}}
+%TODO: error handling
\def\@mod@fpnum@mul#1#2#3{%
\ifx#2\relax
\let\@next@fpnum@mul\@@fin@fpnum@mul
@@ -37,7 +48,7 @@
\fi\fi\@next@fpnum@mul#1}
\def\@@fin@fpnum@mul#1{\xdef#1{\noexpand\@tlabel@fpnum{\strip@pt\@tempdimeni}}}
-\addassoc\@globalenv\fpminus{\@tlabel@func{\@mod@fpnum@minus}}
+\@lisp@env@add@global\fpminus{\@tlabel@func{\@lisp@func@check@args{+}{\@mod@fpnum@minus}}}
\def\@mod@fpnum@minus#1#2#3#4#5{%
\ifx#4\relax
\ifx#2\@tlabel@fpnum
@@ -72,7 +83,7 @@
\fi\fi
\@next@fpnum@minus#1}
-\addassoc\@globalenv\fplt{\@tlabel@func{\@mod@fpnum@lt}}
+\@lisp@env@add@global\fplt{\@tlabel@func{\@lisp@func@check@args{2}{\@mod@fpnum@lt}}}
\def\@mod@fpnum@lt#1\@tlabel@fpnum#2\@tlabel@fpnum#3{%
\ifdim#2pt<#3pt
\gdef#1{\@tlabel@bool{t}}%
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-l3regex.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-l3regex.sty
new file mode 100644
index 00000000000..03b278d3865
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-l3regex.sty
@@ -0,0 +1,99 @@
+% wrapper for l3regex
+\RequirePackage{l3regex}
+
+% \regex_match:nnTF
+\@lisp@env@add@global\regMatch{\@tlabel@func{\@lisp@func@check@args{2}{\@lisp@regex@match}}}
+\ExplSyntaxOn
+\cs_new:Npn \lot_regex_match:Nnn #1#2#3 {
+ \regex_match:nnTF{#2}{#3}{\gdef#1{\@tlabel@bool{t}}}{\gdef#1{\@tlabel@bool{f}}}
+}
+\cs_new_eq:NN \@lisp@regex@match@ \lot_regex_match:Nnn
+\ExplSyntaxOff
+%TODO: error handling
+\def\@lisp@regex@match#1\@tlabel@string#2\@tlabel@string#3{\@lisp@regex@match@#1{#2}{#3}}
+
+% \regex_extract_all
+\@lisp@env@add@global\regExtract{\@tlabel@func{\@lisp@func@check@args{2}{\@lisp@regex@extract}}}
+\ExplSyntaxOn
+\seq_new:N \lot_regex_extract_seq
+\cs_new:Npn \lot_regex_extract:nnN #1#2#3{
+ \regex_extract_all:nnN{#1}{#2}\lot_regex_extract_seq
+ \seq_map_variable:NNn \lot_regex_extract_seq \lot_regex_tmp
+ {\@lisp@regex@add@sep@result#3\lot_regex_tmp}}
+\cs_new_eq:NN \@lisp@regex@extract@ \lot_regex_extract:nnN
+\ExplSyntaxOff
+\def\@lisp@regex@add@sep@result#1#2{\expandafter\@lisp@regex@add@sep@result@\expandafter#1\expandafter{#2}}
+\def\@lisp@regex@add@sep@result@#1#2{\expandafter\def\expandafter#1\expandafter{#1{#2}}}
+\def\@lisp@regex@add@typelabel#1#2{%
+ \gdef#2{}%
+ \@tfor\@lisp@regex@tmp:=#1\do{%
+ \begingroup
+ \toks0\expandafter{\@lisp@regex@tmp}%
+ \toks1\expandafter{#2}%
+ \xdef#2{\the\toks1 \noexpand\@tlabel@string{\the\toks0}}%
+ \endgroup}}
+\def\@lisp@regex@extract#1\@tlabel@string#2\@tlabel@string#3{%
+ \def#1{}%
+ \@lisp@regex@extract@{#2}{#3}#1%
+ \expandafter\@lisp@regex@add@typelabel\expandafter{#1}#1%
+ \expandafter\@lisp@prim@list@pre\expandafter#1#1\relax\relax}
+
+
+% \regex_extract_once
+\@lisp@env@add@global\regMatchResult{\@tlabel@func{\@lisp@func@check@args{2}{\@lisp@regex@extract@once}}}
+\ExplSyntaxOn
+\seq_new:N \lot_regex_extract_once_seq
+\cs_new:Npn \lot_regex_extract_once:nnN #1#2#3{
+ \regex_extract_once:nnN{#1}{#2}\lot_regex_extract_once_seq
+ \seq_map_variable:NNn \lot_regex_extract_once_seq \lot_regex_tmp
+ {\@lisp@regex@add@sep@result#3\lot_regex_tmp}}
+\cs_new_eq:NN \@lisp@regex@extract@once@ \lot_regex_extract_once:nnN
+\ExplSyntaxOff
+\def\@lisp@regex@extract@once#1\@tlabel@string#2\@tlabel@string#3{%
+ \def#1{}%
+ \@lisp@regex@extract@once@{#2}{#3}#1%
+ \expandafter\@lisp@regex@add@typelabel\expandafter{#1}#1%
+ \expandafter\@lisp@prim@list@pre\expandafter#1#1\relax\relax}
+
+% \regex_split
+\@lisp@env@add@global\regSplit{\@tlabel@func{\@lisp@func@check@args{2}{\@lisp@regex@split}}}
+\ExplSyntaxOn
+\seq_new:N \lot_regex_split_seq
+\cs_new:Npn \lot_regex_split:nnN #1#2#3{
+ \regex_split:nnN{#1}{#2}\lot_regex_split_seq
+ \seq_map_variable:NNn \lot_regex_split_seq \lot_regex_tmp
+ {\@lisp@regex@add@sep@result#3\lot_regex_tmp}}
+\cs_new_eq:NN \@lisp@regex@split@ \lot_regex_split:nnN
+\ExplSyntaxOff
+\def\@lisp@regex@split#1\@tlabel@string#2\@tlabel@string#3{%
+ \def#1{}%
+ \@lisp@regex@split@{#2}{#3}#1%
+ \expandafter\@lisp@regex@add@typelabel\expandafter{#1}#1%
+ \expandafter\@lisp@prim@list@pre\expandafter#1#1\relax\relax}
+
+
+
+
+% \regex_replace_once
+\@lisp@env@add@global\regReplaceOnce{\@tlabel@func{\@lisp@func@check@args{3}{\@lisp@regex@replace@once}}}
+\ExplSyntaxOn
+\cs_new_eq:NN \@lisp@regex@replace@once@ \regex_replace_once:nnN
+\ExplSyntaxOff
+%TODO: error handling
+\def\@lisp@regex@replace@once#1\@tlabel@string#2\@tlabel@string#3\@tlabel@string#4{%
+ \def#1{#4}%
+ \@lisp@regex@replace@once@{#2}{#3}#1%
+ \expandafter\gdef\expandafter#1\expandafter{%
+ \expandafter\@tlabel@string\expandafter{#1}}}
+
+% \regex_replace_all
+\@lisp@env@add@global\regReplaceAll{\@tlabel@func{\@lisp@func@check@args{3}{\@lisp@regex@replace@all}}}
+\ExplSyntaxOn
+\cs_new_eq:NN \@lisp@regex@replace@all@ \regex_replace_all:nnN
+\ExplSyntaxOff
+%TODO: error handling
+\def\@lisp@regex@replace@all#1\@tlabel@string#2\@tlabel@string#3\@tlabel@string#4{%
+ \def#1{#4}%
+ \@lisp@regex@replace@all@{#2}{#3}#1%
+ \expandafter\gdef\expandafter#1\expandafter{%
+ \expandafter\@tlabel@string\expandafter{#1}}} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-on-tex.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-on-tex.sty
index 817e8a0a0ae..7b6b79688cf 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-on-tex.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-on-tex.sty
@@ -3,124 +3,160 @@
%%
%% License: Modified BSD - see LICENSE file
%%
-%% input buffer and read function
-
-
-%%===========================================
-%% Macros for Input Programs
-%%===========================================
-
-%%===========================================
-%% Public Field
-%%===========================================
-%% \setinputbuffer : Set the input
-\def\setinputbuffer#1{\gdef\@read@buffer{#1}}
-%% \readchar : Read a letter from the input
-\def\readchar{%
- \ifx\@eof\@read@buffer
- \gdef\@currentread{\@@eof}%
- \else
- \expandafter\@car@buffer\@read@buffer\relax
- \fi}
-%% \unreadchar : Unread a letter from the input
-\def\unreadchar{%
- \ifx\@eof\@currentread\else
- \expandafter\@unreadchar\@currentread
- \gdef\@currentread{}\fi}
-
-%%===========================================
-%% Private Field
-%%===========================================
-\def\@dummy{\@@dummy}
-\def\@read@buffer{} % The input
-\def\@currentread{} % The front letter
-\def\@eof{\@@eof} % EOF
-
-\def\@car@buffer#1#2\relax{\gdef\@currentread{#1}\gdef\@read@buffer{#2}}
-\def\@unreadchar#1{%
- \expandafter\gdef
- \expandafter\@read@buffer
- \expandafter{\expandafter#1\@read@buffer}}
-
-%% assoc \cs -> value
-% constructor
-\def\makeassoc#1{\def#1{}}
-% add member
-\def\addassoc#1#2#3{%#1(assoc),#2(\cs),#3(value)
-\gdef\@temp@add{#3}%
-\expandafter\expandafter\expandafter\gdef\expandafter\expandafter
-\expandafter#1\expandafter\expandafter\expandafter{%
-\expandafter\expandafter\expandafter#2\expandafter\expandafter\expandafter{\expandafter\@temp@add\expandafter}#1}}
-% remove member. It cause error if there is no member
-\def\rmassoc#1#2{% #1(assoc), #2(\cs)
-\def\@rmassoc##1#2##2##3\relax{##1##3}%
-\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter{\expandafter\@rmassoc#1\relax}}
-% exist?
-\def\ifmemassoc#1#2{%
-\expandafter\@ifmemassoc\expandafter#2#1\relax}
-\def\@ifmemassoc#1#2\relax{\ifx\@dummy#2\@dummy\let\@next\@iffalse\else\def\@next{\@@ifmemassoc#1#2\relax}\fi\@next}
-\def\@@ifmemassoc#1#2#3#4\relax{%
-\begingroup\def#1{\@@target}%
-\ifx#1#2\endgroup\let\@next\@iftrue\else\endgroup\def\@next{\@ifmemassoc#1#4\relax}\fi\@next}
-\def\@iffalse{\iffalse}
-\def\@iftrue{\iftrue}
-% get It cause error if there is no member
-\def\getassoc#1#2#3{%
-\def\@getassoc##1#2##2##3\relax{\gdef#3{##2}\relax}\expandafter\@getassoc#1\relax}
-% show
-\def\showassoc#1{\expandafter\@showassoc#1\relax}
-\def\@showassoc#1\relax{\ifx\@dummy#1\@dummy
-\let\@next\relax\else\def\@next{\@@showassoc#1\relax}\fi\@next}
-\def\@@showassoc#1#2#3\relax{\string#1:#2,\ifx\@dummy#3\@dummy\else
-\@showassoc#3\relax\fi}
-
-
-% interface
-\def\@lisp@empty{}
-\def\lispinterp#1{%
- \@lispread\@lisp@read@eval@loop#1\@end@lispread}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{lisp-on-tex}[2015/06/22 v2.0]
+
+\RequirePackage{xkeyval}
+\newcount\@lisp@gc@style
+\def\@lisp@opt@gc{}
+% I use bad magic numbers...
+\DeclareOptionX{noGC}{\@lisp@gc@style0\relax}
+\DeclareOptionX{markGC}{\@lisp@gc@style1\relax}
+\DeclareOptionX{GCopt}[]{\def\@lisp@opt@gc{#1}}
+\ExecuteOptionsX{noGC}
+\ProcessOptionsX
+
+
+% lisp's global environment and some macros for it
+\def\@lisp@globalenv{}
+
+% Bind a variable (#1) to a value (#2) on global environment.
+% This macro also define [@lisp@env@#1] to #2.
+\def\@lisp@env@add@global#1#2{%
+ \begingroup
+ \toks0{#1{#2}}%
+ \toks2\expandafter{\@lisp@globalenv}%
+ \xdef\@lisp@globalenv{\the\toks0 \the\toks2}%
+ \endgroup
+ \expandafter\gdef\csname @lisp@env@\string#1\endcsname{#2}}
+% for backword compability...
+\def\addassoc#1#2#3{\@lisp@env@add@global#2{#3}}
+
+
+% Set a control sequence (#1) to the value of a variable (#2)
+% on a local environment (#3) and global environment.
+% If #2 is unbound, it set #1 to an exception object.
+\def\@lisp@env@get@value#1#2#3{%
+ \def\@lisp@env@tmpmacro##1#2##2##3\@lisp@env@tail{%
+ \gdef#1{##2}}%
+ % I use a sentinel \@lisp@env@get@value@dummy.
+ \@lisp@env@tmpmacro#1#3#2{\@lisp@env@get@value@dummy}%
+ \@lisp@env@tail
+ % #2 is not bound on #3, so I try to get the value
+ % from global environment.
+ \def\@@next#1#2{}%
+ \ifx#1\@lisp@env@get@value@dummy
+ \let\@@next\@lisp@env@get@value@global\fi
+ \@@next#1#2%
+ % not found
+ \def\@@next#1#2{}%
+ \ifx#1\relax\let\@@next\@lisp@env@get@value@notfound\fi
+ \@@next#1#2}
+\def\@lisp@env@get@value@dummy{\@lisp@env@get@value@dummy}
+\def\@lisp@env@get@value@global#1#2{%
+ \expandafter\global\expandafter\let\expandafter#1%
+ \csname @lisp@env@\string#2\endcsname}
+\def\@lisp@env@get@value@notfound#1#2{%
+ \gdef#1{\@tlabel@exception{{-1}{\@tlabel@string{unbound variable #2}}}}}
+
+% ENTRY point of LISP on TeX. It takes a LISP program (#1)
+% and evaluate the program.
+\def\lispinterp#1{\@lispread\@lisp@read@eval@loop#1\@end@lispread}
\def\@lisp@read@eval@loop#1#2{%
+ \ifx#1\@tlabel@exception% read error
+ \let\@@next\@lisp@read@eval@loop@reader@error
+ \else
+ \let\@@next\@lisp@read@eval@loop@normal
+ \fi\@@next#1{#2}}
+\def\@lisp@read@eval@loop@normal#1#2{%
+ \def\@lisp@tmp@global@i{#1{#2}}%
+ \lispeval\@lisp@tmp@global@i\@lisp@tmp@global@i
+ \expandafter\@lisp@read@eval@loop@normal@\@lisp@tmp@global@i}
+\def\@lisp@read@eval@loop@normal@#1#2{%
\ifx#1\@tlabel@exception
- \let\@@next\relax
+ \let\@@next\@lisp@read@eval@loop@catch@error
\else
- \def\@reg@tmp{#1{#2}}%
- \def\@@next{%
- \lispeval\@reg@tmp\@reg@tmp
- \@lispread\@lisp@read@eval@loop}%
- \fi\@@next}
-
-
-% eval
-%% write buffer
-\gdef\@temp@write@buffer{}
-\def\@add@to@write@buffer#1#2{%
- \expandafter\gdef\expandafter#1\expandafter{#1#2}}
+ \let\@@next\@lisp@read@eval@loop@normal@@
+ \fi
+ \@@next#1{#2}}
+\def\@lisp@read@eval@loop@normal@@#1#2{\@lispread\@lisp@read@eval@loop}
-%% global environment
-\makeassoc\@globalenv
+\def\@lisp@read@eval@loop@catch@error\@tlabel@exception#1{%
+ \@lisp@read@eval@loop@print@err#1}
+\def\@lisp@read@eval@loop@print@err#1#2{%
+% #1 -> error handler id, #2 -> error message
+ \@lisp@read@eval@loop@print@err@#2}
+\def\@lisp@read@eval@loop@print@err@#1#2{%
+ \toks0{#2}\errmessage{LISP on TeX ERROR: \the\toks0}%
+ \@lisp@read@eval@loop@gobble@remain}
+\def\@lisp@read@eval@loop@gobble@remain#1\@end@lispread{}
+%FIXME: Now, the reader cannot tell consuming all input from imcomplete
+% input.
+\def\@lisp@read@eval@loop@reader@error\@tlabel@exception#1{}
-% implemeted functions
% CONS CAR CDR
-\newcount\@malloc
-\def\@get@car#1\@tlabel@cons#2{\@@get@car#1#2}
-\def\@@get@car#1#2#3{\global\let#1#2}
-\def\@get@cdr#1\@tlabel@cons#2{\@@get@cdr#1#2}
-\def\@@get@cdr#1#2#3{\global\let#1#3}
-\def\@make@cons#1#2#3#4#5{%
- \expandafter\gdef\csname car\the\@malloc\endcsname{#2{#3}}%
- \expandafter\gdef\csname cdr\the\@malloc\endcsname{#4{#5}}%
- \@@make@cons#1\csname car\the\@malloc\endcsname\csname cdr\the\@malloc\endcsname
- \global\advance\@malloc1\relax}
-\def\@@make@cons#1{\expandafter\@@@make@cons\expandafter#1}
-\def\@@@make@cons#1#2{\expandafter\@@@@make@cons\expandafter#1\expandafter#2}
-\def\@@@@make@cons#1#2#3{\gdef#1{\@tlabel@cons{#2#3}}}
-
-
-\def\@defined@datatype{symbol,string,int,bool,dimen,skip,cons,nil,func,closure,macro,envfunc,mutable,exception,continuation}
-\def\@defined@specialform{lambda,quote,define,if,defmacro,begin,mdefine,setb,@let,@mlet,macroexpand,callocc}
+% get CAR of a CONS cell (#2{#3}) and set it to a control sequence
+% (#1). If the argument is not a CONS cell, it raise an exception.
+\def\@lisp@perform@car#1#2#3{%
+ \ifx#2\@tlabel@cons
+ \let\@@next\@lisp@perform@car@normal
+ \else
+ \let\@@next\@lisp@perform@car@type@error
+ \fi
+ \@@next#1{#3}}
+\def\@lisp@perform@car@normal#1#2{\@lisp@perform@car@normal@#1#2}
+\def\@lisp@perform@car@normal@#1#2#3{\global\let#1#2}
+\def\@lisp@perform@car@type@error#1#2{%
+ \gdef#1{\@tlabel@exception{{-1}%
+ {\@tlabel@string{Argument of car must be a CONS cell.}}}}}
+% get CDR of a CONS cell (#2{#3}) and set it to a control sequence
+% (#1). If the argument is not a CONS cell, it raise an exception.
+\def\@lisp@perform@cdr#1#2#3{%
+ \ifx#2\@tlabel@cons
+ \let\@@next\@lisp@perform@cdr@normal
+ \else
+ \let\@@next\@lisp@perform@cdr@type@error
+ \fi
+ \@@next#1{#3}}
+\def\@lisp@perform@cdr@normal#1#2{\@lisp@perform@cdr@normal@#1#2}
+\def\@lisp@perform@cdr@normal@#1#2#3{\global\let#1#3}
+\def\@lisp@perform@cdr@type@error#1#2{%
+ \gdef#1{\@tlabel@exception{{-1}%
+ {\@tlabel@string{Argument of cdr must be a CONS cell.}}}}}
+% create a CONS cell whose CAR is #2{#3} and CDR is #4{#5}.
+% It set a control sequence (#1) to the created cell.
+\def\@lisp@perform@cons#1#2#3#4#5{%
+ \@lisp@perform@cons@local#1#2{#3}#4{#5}%
+ \global\let#1#1}
+\def\@lisp@perform@cons@local#1#2#3#4#5{%
+ \@lisp@gc@save@objects@local{#2{#3}#4{#5}}% pin arguments
+ \@lisp@gc@alloc\@lisp@tmp@local@i
+ \expandafter\@lisp@gc@save@memory@local\expandafter{\@lisp@tmp@local@i}% pin CAR
+ \@lisp@gc@alloc\@lisp@tmp@local@ii
+ \expandafter\gdef\@lisp@tmp@local@i{#2{#3}}%
+ \expandafter\gdef\@lisp@tmp@local@ii{#4{#5}}%
+ \expandafter\@lisp@perform@cons@\expandafter#1%
+ \@lisp@tmp@local@i\@lisp@tmp@local@ii}
+\def\@lisp@perform@cons@#1#2#3{%
+ \expandafter\@lisp@perform@cons@@\expandafter#1%
+ \expandafter#2#3}
+\def\@lisp@perform@cons@@#1#2#3{\def#1{\@tlabel@cons{#2#3}}}
+
+
+% all primitive types of LISP on TeX.
+\def\@defined@datatype{%
+ symbol,string,int,bool,dimen,skip,cons,nil,%
+ func,closure,macro,envfunc,mutable,%
+ exception,continuation}
+% all special forms of LISP on TeX
+\def\@defined@specialform{%
+ lambda,quote,define,if,defmacro,begin,%
+ mdefine,setb,@let,@mlet,macroexpand,callocc}
\edef\@defined@lisp@on@tex{\@defined@datatype,\@defined@specialform}
+% all additional types of LISP on TeX
+\def\@defined@additional@type{}
%%%%%MEMO
@@ -140,73 +176,51 @@
\def\@@@@type@define@field#1#2#3#4{%
\def#1##1##2##3{\gdef##3{#4{##1}}}%
\def#2{\errmessage{LISP on TeX [internal apply]: cannot apply}}%
- \def#3{\errmessage{LISP on teX [function --- apply]: cannot apply}}%
+ \def#3{\errmessage{LISP on TeX [function --- apply]: cannot apply}}%
\def#4{#1#2#3}}
-\@for\@type:=\@defined@lisp@on@tex\do{%
+\@for\@lisp@on@tex@type:=\@defined@lisp@on@tex\do{%
\expandafter\@type@define@filed%
- \csname @eval@\@type\endcsname%
- \csname @apply@\@type\endcsname%
- \csname @@apply@\@type\endcsname%
- \csname @tlabel@\@type\endcsname}
-
+ \csname @eval@\@lisp@on@tex@type\endcsname%
+ \csname @apply@\@lisp@on@tex@type\endcsname%
+ \csname @@apply@\@lisp@on@tex@type\endcsname%
+ \csname @tlabel@\@lisp@on@tex@type\endcsname}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% memo of fasteval branch
-% Each bound variables \var
-% is defined as TeX macro [[@lisp@env@\var]]
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\def\@lisp@expand@env@last{\@lisp@expand@env@last}
-\def\@lisp@expand@environment#1#2#3\@lisp@expand@env@last{%
- \def\@@tmp@lisp@env{#3}%
- \def\@@tmp{\expandafter\def\csname @lisp@env@\string#1\endcsname{#2}}%
- \ifx\@empty\@@tmp@lisp@env
- \let\@@next\relax
- \else
- \def\@@next{\@lisp@expand@environment#3\@lisp@expand@env@last}%
- \fi
- \expandafter\@@next\@@tmp}
+% write buffer. LISP on TeX's evaluator
+\gdef\@temp@write@buffer{}
+\def\@add@to@write@buffer#1#2{%
+ \expandafter\gdef\expandafter#1\expandafter{#1#2}}
\def\lispeval#1#2{% #1 : \cs -> S-exp, #2 : target register
- \gdef\@temp@write@buffer{}%
- \expandafter\def\expandafter\@@tmp@lisp@env\expandafter{\@globalenv}%
- \ifx\@empty\@globalenv\else
- \expandafter\@lisp@expand@environment\@globalenv\@lisp@expand@env@last\fi
+ \gdef\@temp@write@buffer{}%
+ \@lisp@eval@save@envfalse
\expandafter\@eval#1{}#2%
- \@temp@write@buffer}
+ \@temp@write@buffer}
+\newif\if@lisp@eval@save@env
\def\@eval#1#2#3#4{%
\begingroup
- \def\@@tmp@lisp@env{#3}%
- \ifx\@empty\@@tmp@lisp@env\else
- \@lisp@expand@environment#3\@lisp@expand@env@last\fi
+ % pin target S-exp object.
+ \if@lisp@eval@save@env
+ \@lisp@eval@save@envfalse
+ \expandafter\@lisp@gc@save@env@local
+ \else
+ \expandafter\@gobble
+ \fi{#3}%
+ \@lisp@gc@save@objects@local{#1{#2}}%
\expandafter\@@select@eval#1{#2}{#3}#4%
\endgroup}
-\def\@append@env@global#1#2{%
- \def#2{#1}%
- \expandafter\expandafter\expandafter\def
- \expandafter\expandafter\expandafter#2%
- \expandafter\expandafter\expandafter{\expandafter#2\@globalenv}}
-\def\@eval@symbol#1#2#3{% #1 symbol #2 current env (ignored) #3 dist
- \expandafter\global\expandafter\let\expandafter#3\csname @lisp@env@\string#1\endcsname
- \ifx#3\relax % not found
- \errmessage{LISP on TeX [evaluation of a symbol]: unbound variable...}%
- \else
- \expandafter\@expand@if@mutable#3#3%
- \fi}
-\def\@expand@if@mutable#1#2#3{%
- \let\@@next\@expand@if@mutable@next@f
- \ifx#1\@tlabel@mutable\let\@@next\@expand@if@mutable@next@t\fi
- \@@next{#2}{#3}}
-\def\@expand@if@mutable@next@f#1#2{}
-\def\@expand@if@mutable@next@t#1#2{\global\let#2#1}
+\def\@eval@symbol#1#2#3{% #1 symbol #2 current env #3 dist
+ \@lisp@env@get@value#3#1{#2}%
+ \expandafter\@eval@symbol@expand@mutable#3#3}
+\def\@eval@symbol@expand@mutable#1#2#3{%
+ \ifx#1\@tlabel@mutable\global\let#3#2\fi}
\def\@@eval@get@typelabel#1#2{#1}
-
\def\@eval@envcs#1#2#3#4{\expandafter\@@eval@envcs\expandafter{#1}#2{#3}#4}
\def\@@eval@envcs#1#2#3#4{\@eval#2{#3}{#1}#4}
@@ -218,12 +232,24 @@
\let\@@next\@@eval@cons@exception\else\let\@@next\@@eval@cons@normal\fi
\@@next{#2}{#3}{#4}}
\def\@@eval@cons@normal#1#2#3{%
+ \expandafter\@lisp@gc@save@objects@local\expandafter{\@temp@i}% pin evaluated value of CAR
\def\@temp@ii{}% init
- \expandafter\@flatten@args#1\@temp@ii
- \expandafter\expandafter\expandafter\@@select@apply@pre
- \expandafter\@temp@i\@temp@ii\@{#2}#3}
+ \expandafter\@flatten@args#1\@temp@ii % args are already pined, maybe...
+ %error-check of argument form
+ \ifx\@temp@ii\@@flatten@error@symbol
+ \let\@@next\@@eval@cons@args@error
+ \else
+ \let\@@next\@@eval@cons@apply
+ \fi
+ \@@next{#2}{#3}}
\def\@@select@apply@pre{\expandafter\@@select@apply}
\def\@@eval@cons@exception#1#2#3{\global\let#3\@temp@i}
+\def\@@eval@cons@apply#1#2{%
+ \expandafter\expandafter\expandafter\@@select@apply@pre
+ \expandafter\@temp@i\@temp@ii\@{#1}#2}
+\def\@@eval@cons@args@error#1#2{%
+ \gdef#2{\@tlabel@exception{%
+ {-1}{\@tlabel@string{Eval Improper List}}}}}
\def\@flatten@args#1#2#3{%
\ifx#1\@tlabel@cons
@@ -231,17 +257,17 @@
\else\ifx#1\@tlabel@nil
\let\@flatten@next\@@flatten@fin
\else
- \errmessage{LISP on TeX [internal apply]: Invalid args}%
+ \let\@flatten@next\@@flatten@error
\fi\fi
\@flatten@next#2#3}
-
\def\@@flatten@next#1#2#3{%
\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter#3%
\expandafter\expandafter\expandafter{\expandafter#3#1}%
\expandafter\@flatten@args#2#3}
-
\def\@@flatten@fin#1{}
+\def\@@flatten@error#1#2{\def#2{error}}
+\def\@@flatten@error@symbol{error}
\def\@apply@lambda#1#2#3#4#5\@#6#7{%
\def\@lambda@args{}% init
@@ -268,56 +294,128 @@
\def\@apply@quote#1#2#3\@#4#5{\gdef#5{#2{#3}}}
-\def\@apply@define#1\@tlabel@symbol#2#3#4\@#5#6{%
+% application of define, defineM, defmacro.
+% #1 empty, #2{#3} 1st argument, #4{#5} 2nd argument,
+% #6 env, #7 cs
+\def\@apply@define#1#2#3#4#5\@#6#7{%
+ \let\@lisp@define@normal\@apply@define@normal
+ \@apply@define@{#1}#2{#3}#4{#5}\@{#6}#7}
+\def\@apply@mdefine#1#2#3#4#5\@#6#7{%
+ \let\@lisp@define@normal\@apply@mdefine@normal
+ \@apply@define@{#1}#2{#3}#4{#5}\@{#6}#7}
+\def\@apply@defmacro#1#2#3#4#5\@#6#7{%
+ \let\@lisp@define@normal\@apply@defmacro@normal
+ \@apply@define@{#1}#2{#3}#4{#5}\@{#6}#7}
+% type check
+\def\@apply@define@#1#2#3#4#5\@#6#7{%
+ \ifx#2\@tlabel@symbol % normal style
+ \let\@@next\@apply@define@@
+ \else\ifx#2\@tlabel@cons % function definition
+ \let\@@next\@apply@define@func
+ \else
+ \let\@@next\@apply@define@error
+ \fi\fi
+ \@@next{#1}#2{#3}#4{#5}\@{#6}#7}
+% \define's normal form
+\def\@apply@define@normal#1#2{%
+ \expandafter\@lisp@env@add@global\expandafter#1\expandafter{#2}%
+ \gdef#2{\@tlabel@nil{}}}
+% \defineM's normal form
+\def\@apply@mdefine@normal#1#2{%
+ \@lisp@gc@save@objects@local{#2}% pin the evaluated value
+ \@lisp@gc@alloc\@lisp@tmp@local@i
+ \expandafter\global\expandafter\let\@lisp@tmp@local@i#2%
+ \expandafter\@apply@mdefine@normal@\@lisp@tmp@local@i#1%
+ \gdef#2{\@tlabel@nil{}}}
+\def\@apply@mdefine@normal@#1#2{%
+ \@lisp@env@add@global#2{\@tlabel@mutable{#1}}}
+% \defmacro's normal form
+\def\@apply@defmacro@normal#1#2{%
+ \expandafter\@apply@defmacro@next\expandafter#1#2%
+ \gdef#2{\@tlabel@nil{}}}
+%TODO: error handling
+\def\@apply@defmacro@next#1\@tlabel@closure#2{%
+ \@lisp@env@add@global#1{\@tlabel@macro{#2}}}
+% normal form
+\def\@apply@define@@#1\@tlabel@symbol#2#3#4\@#5#6{%
\@eval#3{#4}{#5}#6% define does NOT use local environment
\expandafter\expandafter\expandafter\ifx
\expandafter\@@eval@get@typelabel#6\@tlabel@exception
\let\@@next\@apply@define@exception
- \else\let\@@next\@apply@define@normal\fi
+ \else\let\@@next\@lisp@define@normal\fi
\@@next{#2}{#6}}
-
+% function form
+\def\@apply@define@func#1\@tlabel@cons#2#3#4\@#5#6{%
+ \@apply@define@func@#2#3{#4}\@{#5}#6}
+\def\@apply@define@func@#1#2#3#4\@#5#6{%
+ \expandafter\expandafter\expandafter\ifx
+ \expandafter\@@eval@get@typelabel#1\@tlabel@symbol
+ \let\@@next\@apply@define@func@@
+ \else
+ \let\@@next\@apply@define@error
+ \fi
+ \@@next#1#2#3{#4}\@{#5}#6}
+\def\@apply@define@func@@#1#2#3#4\@#5#6{% notice: no tmp token remain the closure
+ \def\@lisp@tmp@local@i{#3{#4}}% closure body
+ \def\@lisp@tmp@local@ii{\@tlabel@nil{}}%
+ \def\@lisp@tmp@local@iii{\@tlabel@cons{\@lisp@tmp@local@i\@lisp@tmp@local@ii}}%
+ \expandafter\def\expandafter\@lisp@tmp@local@iv\expandafter{#2}% formal arguments
+ \def\@lisp@tmp@local@v{\@tlabel@cons{\@lisp@tmp@local@iv\@lisp@tmp@local@iii}}%
+ \def\@lisp@tmp@local@vi{\@tlabel@lambda{}}% \lambda
+ \expandafter\@apply@define@@\expandafter{\expandafter}#1\@tlabel@cons{\@lisp@tmp@local@vi\@lisp@tmp@local@v}\@{#5}#6}
+% type error
+\def\@apply@define@error#1\@#2#3{%
+ \gdef#3{\@tlabel@exception{{-1}
+ {\@tlabel@string{The 1st argument of \define or \defineM must be a symbol or valid list.}}}}}
+% catch exception at evaluation
\def\@apply@define@exception#1#2{}
-\def\@apply@define@normal#1#2{%
- \expandafter\addassoc\expandafter\@globalenv\expandafter#1\expandafter{#2}%
- \gdef#2{\@tlabel@nil{}}}
-\def\@apply@mdefine#1\@tlabel@symbol#2#3#4\@#5#6{%
- \@eval#3{#4}{#5}#6% mdefine does NOT use local environment
+\def\@apply@setb#1#2#3#4#5\@#6#7{%
+ \ifx\@tlabel@symbol#2%
+ \let\@@next\@apply@setb@normal
+ \else
+ \let\@@next\@apply@setb@argtype@symbol@error
+ \fi
+ \@@next#3#4{#5}{#6}#7}
+\def\@apply@setb@normal#1#2#3#4#5{%
+ \@lisp@env@get@value#5#1{#4}%
\expandafter\expandafter\expandafter\ifx
- \expandafter\@@eval@get@typelabel#6\@tlabel@exception
- \let\@@next\@apply@define@exception
- \else\let\@@next\@apply@mdefine@normal\fi
- \@@next{#2}{#6}}
-
-\def\@apply@mdefine@normal#1#2{%
- \expandafter\@mutable@allocate#2%
- \expandafter\addassoc
- \expandafter\@globalenv
- \expandafter#1%
- \expandafter{\expandafter\@tlabel@mutable
- \expandafter{\csname mutable\the\@malloc\endcsname}}%
- \global\advance\@malloc1\relax
+ \expandafter\@@eval@get@typelabel#5\@tlabel@exception
+ \let\@@next\@apply@setb@raise@exception
+ \else\expandafter\expandafter\expandafter\ifx
+ \expandafter\@@eval@get@typelabel#5\@tlabel@mutable
+ \let\@@next\@apply@setb@normal@
+ \else
+ \let\@@next\@apply@setb@argtype@mutable@error
+ \fi\fi
+ \@@next#1#2{#3}{#4}#5}
+\def\@apply@setb@normal@#1#2#3#4#5{%
+ % the environment and the value is already pinned, maybe...
+ \let\@lisp@tmp@local@i#5%
+ \@eval#2{#3}{#4}#5%
+ \expandafter\expandafter\expandafter\ifx
+ \expandafter\@@eval@get@typelabel#5\@tlabel@exception
+ \let\@@next\@apply@setb@raise@exception
+ \else
+ \let\@@next\@apply@setb@normal@@
+ \fi
+ \@@next#1#2{#3}{#4}#5}
+\def\@apply@setb@normal@@#1#2#3#4#5{%
+ \expandafter\@apply@setb@final\@lisp@tmp@local@i#5}
+\def\@apply@setb@final\@tlabel@mutable#1#2{%
+ \global\let#1#2%
\gdef#2{\@tlabel@nil{}}}
-\def\@mutable@allocate#1#2{\expandafter\gdef\csname mutable\the\@malloc\endcsname{#1{#2}}}
+\def\@apply@setb@argtype@symbol@error#1#2#3#4#5{%
+ \gdef#5{\@tlabel@exception{{-1}%
+ {\@tlabel@string{The 1st argument of \setB must be a symbol}}}}}
+\def\@apply@setb@raise@exception#1#2#3#4#5{}
+\def\@apply@setb@argtype@mutable@error#1#2#3#4#5{%
+ \gdef#5{\@tlabel@exception{{-1}%
+ {\@tlabel@string{The symbol #1 is not defined as a 'mutable'. %
+ Use \defineM, \letM, or \letrec.}}}}}
-\def\@apply@setb#1\@tlabel@symbol#2#3#4\@#5#6{%
- \@eval#3{#4}{#5}#6%
- \expandafter\expandafter\expandafter\ifx
- \expandafter\@@eval@get@typelabel#6\@tlabel@exception
- \let\@@next\@apply@setb@exception
- \else\let\@@next\@apply@setb@normal\fi
- \@@next{#2}{#5}{#6}}
-\def\@apply@setb@normal#1#2#3{%
- \let\@@save#3%
- \@append@env@global{#2}\@temp@env
- \getassoc\@temp@env#1\@temp@i
- \let#3\@@save%
- \expandafter\@set@mutable\@temp@i#3%
- \gdef#3{\@tlabel@nil{}}}
-\def\@set@mutable\@tlabel@mutable#1#2{\global\let#1#2}
-\def\@apply@setb@exception#1#2#3{}
-
+%TODO: error handling
\def\@apply@@let#1\@tlabel@symbol#2#3#4#5#6\@#7#8{%
\@eval#3{#4}{#7}#8%
\expandafter\expandafter\expandafter\ifx
@@ -327,11 +425,21 @@
\@@next{#2}{#5}{#6}{#7}{#8}}
\def\@apply@@let@normal#1#2#3#4#5{%
\expandafter\def\expandafter\@temp@env\expandafter{\expandafter#1\expandafter{#5}#4}%
- \expandafter\gdef\expandafter\@@tco
- \expandafter{\expandafter\@@eval@envcs\expandafter{\@temp@env}#2{#3}#5}%
+ \begingroup
+ \toks0\expandafter{\@temp@env}%
+ \toks1{#2{#3}#5}%
+ \toks2\expandafter{#5}%
+ \xdef\@@tco{%
+ \begingroup
+ \noexpand\@lisp@eval@save@envtrue
+ \noexpand\@lisp@gc@save@objects@local{\the\toks2}% pin appended value
+ \noexpand\@@eval@envcs{\the\toks0}\the\toks1
+ \endgroup}%
+ \endgroup
\aftergroup\@@tco}
-\def\@apply@@let@exception#1#2#3#4#5{}
+\def\@apply@@let@exception#1#2#3#4#5{} % #5 is already set the value of exception
+%TODO: error handling
\def\@apply@@mlet#1\@tlabel@symbol#2#3#4#5#6\@#7#8{%
\@eval#3{#4}{#7}#8%
\expandafter\expandafter\expandafter\ifx
@@ -339,27 +447,27 @@
\let\@@next\@apply@@let@exception
\else\let\@@next\@apply@@mlet@normal\fi
\@@next{#2}{#5}{#6}{#7}{#8}}
+
\def\@apply@@mlet@normal#1#2#3#4#5{%
- \expandafter\global\expandafter\let\csname mutable\the\@malloc\endcsname#5%
- \expandafter\def\expandafter#5\expandafter{\expandafter\@tlabel@mutable
- \expandafter{\csname mutable\the\@malloc\endcsname}}%
- \global\advance\@malloc1\relax
- \expandafter\def\expandafter\@temp@env\expandafter{\expandafter#1\expandafter{#5}#4}%
- \expandafter\gdef\expandafter\@@tco
- \expandafter{\expandafter\@@eval@envcs\expandafter{\@temp@env}#2{#3}#5}%
+ \expandafter\@lisp@gc@save@objects@local\expandafter{#5}% pin target value
+ \@lisp@gc@alloc\@lisp@tmp@local@i
+ \expandafter\global\expandafter\let\@lisp@tmp@local@i#5%
+ \expandafter\@apply@@mlet@normal@\@lisp@tmp@local@i#1{#4}%
+ \begingroup
+ \toks0\expandafter{\@lisp@tmp@local@ii}%
+ \toks1{#2{#3}#5}%
+ \toks2\expandafter{\@lisp@tmp@local@i}%
+ \xdef\@@tco{%
+ \begingroup
+ \noexpand\@lisp@eval@save@envtrue
+ \noexpand\@lisp@gc@save@memory@local{\the\toks2}% pin the appended value
+ \noexpand\@@eval@envcs{\the\toks0}\the\toks1
+ \endgroup}%
+ \endgroup
\aftergroup\@@tco}
+\def\@apply@@mlet@normal@#1#2#3{%
+ \def\@lisp@tmp@local@ii{#2{\@tlabel@mutable{#1}}#3}}
-\def\@apply@defmacro#1\@tlabel@symbol#2#3#4\@#5#6{%
- \@eval#3{#4}{#5}#6% NOT use local env!
- \expandafter\expandafter\expandafter\ifx
- \expandafter\@@eval@get@typelabel#6\@tlabel@exception
- \let\@@next\@apply@define@exception
- \else\let\@@next\@apply@defmacro@normal\fi
- \@@next{#2}{#6}}
-\def\@apply@defmacro@normal#1#2{%
- \expandafter\@apply@defmacro@next\expandafter#1#2%
- \gdef#2{\@tlabel@nil{}}}
-\def\@apply@defmacro@next#1\@tlabel@closure#2{\addassoc\@globalenv#1{\@tlabel@macro{#2}}}
\def\@apply@if#1#2#3#4#5#6#7\@#8#9{%
\@eval#2{#3}{#8}#9%
@@ -373,18 +481,28 @@
\aftergroup\@@tco}
\def\@apply@if@exception#1#2#3#4#5#6{}
-\def\@apply@if@next\@tlabel@bool#1#2#3#4#5#6#7{%
- \let\@@next\relax
- \ifx#1t%
- \let\@@next\@apply@if@next@t
- \else\ifx#1f%
- \let\@@next\@apply@if@next@f
+% #1{#2} -> condition, #3{#4} -> then, #5{#6} -> else, #7 -> env, #8 ->cs
+\def\@apply@if@next#1#2#3#4#5#6#7#8{%
+ \ifx#1\@tlabel@bool
+ \ifx#2t%
+ \let\@@next\@apply@if@next@t
+ \else\ifx#2f%
+ \let\@@next\@apply@if@next@f
+ \else
+ \let\@@next\@apply@if@next@invalid
+ \fi\fi
\else
- \errmessage{LISP on TeX [if]: Invalid boolean. It's BUG. Please report.}%
- \fi\fi\@@next{#1}{#2}{#3}{#4}{#5}{#6}{#7}}
-\def\@apply@if@next@t#1#2#3#4#5#6#7{\gdef\@@tco{\@eval#2{#3}{#6}#7}}
-\def\@apply@if@next@f#1#2#3#4#5#6#7{\gdef\@@tco{\@eval#4{#5}{#6}#7}}
-
+ \let\@@next\@apply@if@next@type@error
+ \fi
+ \@@next#3{#4}#5{#6}{#7}#8}
+\def\@apply@if@next@t#1#2#3#4#5#6{\gdef\@@tco{\@eval#1{#2}{#5}#6}}
+\def\@apply@if@next@f#1#2#3#4#5#6{\gdef\@@tco{\@eval#3{#4}{#5}#6}}
+\def\@apply@if@next@invalid#1#2#3#4#5#6{%
+ \gdef\@@tco{\gdef#6{\@tlabel@exception{%
+ {-1}{\@tlabel@string{Fatal. Invalid Boolean}}}}}}
+\def\@apply@if@next@type@error#1#2#3#4#5#6{%
+ \gdef\@@tco{\gdef#6{\@tlabel@exception{%
+ {-1}{\@tlabel@string{The condition must be a bool.}}}}}}
%% use general
\def\@apply@eval@args#1#2#3#4{%
@@ -394,11 +512,11 @@
\else
\let\@@next@pre\@apply@eval@args@pre@i
\fi\@@next@pre{#1}{#2}{#3}{#4}\@@next#1{#2}}
-
\def\@apply@eval@args@pre@default#1#2#3#4{}
\def\@apply@eval@args@pre@i#1#2#3#4{%
\let\@@save#1%
\@eval#3{#4}{#2}#1%
+ \expandafter\@lisp@gc@save@objects@local\expandafter{#1}% pin evaluated value
\expandafter\expandafter\expandafter\ifx
\expandafter\@@eval@get@typelabel#1\@tlabel@exception
\let\@@next\@apply@eval@args@exception
@@ -419,6 +537,7 @@
\def\@apply@func#1#2\@#3#4{%
\def\@temp@i{}%
\def\@@dummy@temp@i{}%
+ \@lisp@gc@save@objects@local{\@tlabel@func{#1}}% pin function
\@apply@eval@args\@temp@i{#3}#2\relax\relax
\ifx\@@dummy@temp@i\@temp@i%
\def\@@test@temp@i{\@tlabel@dummy{}}%
@@ -438,11 +557,18 @@
\def\@apply@func@exception#1#2#3{%
\expandafter\gdef\expandafter#3\expandafter{\@temp@i}}
-\def\@@apply@func#1#2\@#3#4{\gdef\@@tco{#1#4#2\relax\relax}\aftergroup\@@tco}
+\def\@@apply@func#1#2\@#3#4{%
+ \gdef\@@tco{%
+ % pin arguments because this stack will be fold.
+ \begingroup
+ \@lisp@gc@save@objects@local{#2}%
+ #1#4#2\relax\relax
+ \endgroup}\aftergroup\@@tco}
\def\@apply@envfunc#1#2\@#3#4{%
\def\@temp@i{}%
\def\@@dummy@temp@i{}%
+ \@lisp@gc@save@objects@local{\@tlabel@envfunc{#1}}% pin function
\@apply@eval@args\@temp@i{#3}#2\relax\relax
\ifx\@temp@i\@@dummy@temp@i%
\def\@@test@temp@i{\@tlabel@dummy{}}%
@@ -460,12 +586,20 @@
\expandafter\@apply@envfunc@next\expandafter{\@temp@i}{#1}{#2}#3}
\def\@apply@envfunc@next#1#2#3#4{\@@apply@envfunc{#2}#1\@{#3}#4}
-\def\@@apply@envfunc#1#2\@#3#4{\gdef\@@tco{#1#4{#3}#2\relax\relax}\aftergroup\@@tco}
+\def\@@apply@envfunc#1#2\@#3#4{%
+ \gdef\@@tco{%
+ \begingroup
+ \@lisp@gc@save@objects@local{#2}%
+ \@lisp@eval@save@envtrue%
+ #1#4{#3}#2\relax\relax
+ \endgroup}\aftergroup\@@tco}
\def\@apply@closure#1#2\@#3#4{%
\def\@temp@i{}%
\def\@@dummy@temp@i{}%
+ \@lisp@gc@save@objects@local{\@tlabel@closure{#1}}% pin closure
+ \@lisp@gc@save@objects@local{#2}% pin arguments
\@apply@eval@args\@temp@i{#3}#2\relax\relax
\ifx\@temp@i\@@dummy@temp@i%
\def\@@test@temp@i{\@tlabel@dummy{}}%
@@ -486,91 +620,149 @@
\def\@@apply@closure#1#2\@#3#4{\@@apply@closure@next#1#2\@#4}
\def\@@apply@closure@next#1#2#3#4#5\@#6{%
\def\@temp@env{}%
+ \@lisp@gc@save@objects@local{#5}% pin arguments
\@@apply@create@env\@temp@env#1#5\relax\relax
- \expandafter\gdef\expandafter\@@tco\expandafter{%
- \expandafter\@@eval@envcs\expandafter{\@temp@env#2}#3{#4}#6}%
+ \begingroup
+ \toks0\expandafter{\@temp@env#2}%
+ \toks1{#3{#4}#6}%
+ \xdef\@@tco{%
+ \noexpand\@lisp@eval@save@envtrue
+ \noexpand\@@eval@envcs{\the\toks0}\the\toks1}%
+ \endgroup
\aftergroup\@@tco}
-\def\@@apply@create@env#1#2:#3#4#5{%
- \let\@@next@pre\@@apply@create@env@pre@default
- \ifx!#2!% if #2 is empty
- \let\@@next@args@\@empty
+% create an environment using in evaluation of closure's body.
+% It set a control sequence (#1) to the created environment locally.
+% #2 is formal arguments and #3 is rest argument. If there is
+% no rest argument, #3 is \@@unused. If an error occurs, it set
+% #1 to \relax by \let.
+\def\@@apply@create@env#1#2:#3{%
+ \def#1{}% initialize
+ \@@apply@create@env@#1{#2}{#3}}
+\def\@@apply@create@env@#1#2#3{%
+ \ifx!#2!% If #2 is empty
\ifx#3\@@unused
- \let\@@next\@@apply@create@env@fin
+ \let\@@next\@@apply@create@env@bind@fin
\else
- \ifx#4\relax
- \let\@@next\@@apply@create@env@fin
- \@@apply@modify@env#1\@tlabel@nil{}#3\@
- \else
- \let\@@next@pre\@@apply@create@env@pre@i
- \fi
+ \let\@@next\@@apply@create@env@bind@rest
\fi
\else
- \let\@@next@pre\@@apply@create@env@pre@ii
- \fi\@@next@pre{#1}{#2}{#3}{#4}{#5}\expandafter\@@next\expandafter#1\@@next@args@:#3}
-
-\def\@@apply@create@env@pre@default#1#2#3#4#5{}
-\def\@@apply@create@env@pre@i#1#2#3#4#5{%
- \@@apply@create@env@phantom
- \expandafter\@@apply@modify@env\expandafter#1\@@@@ph#3\@
- \expandafter\gdef\csname car\the\@malloc\endcsname{#4{#5}}%
- \let\@@next\@@apply@create@env@cdr}
-\def\@@apply@create@env@pre@ii#1#2#3#4#5{%
- \@@apply@modify@env#1#4{#5}#2\@
- \@@next@args#2\@
- \let\@@next\@@apply@create@env}
-
-
-\def\@@apply@create@env@cdr#1:#2{\@@@apply@create@env@cdr}
-\def\@@@apply@create@env@cdr#1#2{%
+ \let\@@next\@@apply@create@env@bind@one
+ \fi
+ \@@next#1#2|{#3}}
+% end of environment creation. If there are some
+% remaining arguments, it cause error.
+\def\@@apply@create@env@bind@fin#1|#2#3#4{%
+ \ifx#3\relax\else
+ \let#1\relax
+ \def\@@apply@create@env@error@message{Too more arguments}%
+ \fi}
+% bind a formal argument. #5{#6} is an real argument
+% of closure/macro call. If there is no unbound argument,
+% #5 and #6 are \relax (see caller).
+\def\@@apply@create@env@bind@one#1#2#3|#4#5#6{%
+ \ifx#5\relax
+ \let\@@next\@@apply@create@env@bind@one@error
+ \else
+ \let\@@next\@@apply@create@env@bind@one@
+ \fi
+ \@@next#1#2{#3}{#4}{#5{#6}}}
+\def\@@apply@create@env@bind@one@#1#2#3#4#5{%
+ \expandafter\def\expandafter#1\expandafter{#1#2{#5}}%
+ \@@apply@create@env@#1{#3}{#4}}
+\def\@@apply@create@env@bind@one@error#1#2#3#4#5{%
+ \def\@@apply@create@env@error@message{Too few arguments}%
+ \let#1\relax}
+% bind a rest argument (#2).
+\def\@@apply@create@env@bind@rest#1|#2{%
+ \def\@lisp@tmp@local@i{#1#2}%
+ \def\@lisp@tmp@local@ii{}%
+ \@@apply@create@env@bind@rest@}
+% get all remaining arguments and create a list.
+% it set the result to \@lisp@tmp@local@iii
+\def\@@apply@create@env@bind@rest@#1#2{%
\ifx#1\relax
- \expandafter\gdef\csname cdr\the\@malloc\endcsname{\@tlabel@nil{}}%
- \global\advance\@malloc1\relax
- \let\@@next\relax
+ \let\@@next\@@apply@create@env@bind@rest@create@cell
\else
- \global\advance\@malloc1\relax
- \@@apply@create@env@phantom
- \global\advance\@malloc-1\relax
- \expandafter\@@set@cdr\@@@@ph
- \global\advance\@malloc1\relax
- \expandafter\gdef\csname car\the\@malloc\endcsname{#1{#2}}%
- \let\@@next\@@@apply@create@env@cdr
- \fi\@@next}
-
-\def\@@set@cdr#1#2{\expandafter\gdef\csname cdr\the\@malloc\endcsname{#1{#2}}}
-\def\@@apply@create@env@phantom{%
- \expandafter\@@@apply@ph\csname car\the\@malloc\endcsname\csname cdr\the\@malloc\endcsname}
-\def\@@@apply@ph#1{\expandafter\@@@@apply@ph\expandafter#1}
-\def\@@@@apply@ph#1#2{\def\@@@@ph{\@tlabel@cons{#1#2}}}
-\def\@@apply@create@env@fin#1:#2{}
-\def\@@apply@modify@env#1#2#3#4#5\@{%
- \ifx#2\relax
- \errmessage{LISP on TeX [apply --- closure]: too few args}%
+ \let\@@next\@@apply@create@env@bind@rest@reverse
+ \fi
+ \@@next#1{#2}}
+% reverse the arguments' order and set it to \@lisp@tmp@local@ii
+\def\@@apply@create@env@bind@rest@reverse#1#2{%
+ \toks0{#1{#2}}%
+ \toks2\expandafter{\@lisp@tmp@local@ii}%
+ \edef\@lisp@tmp@local@ii{\the\toks0 \the\toks2}%
+ \@@apply@create@env@bind@rest@}
+% create a list
+\def\@@apply@create@env@bind@rest@create@cell#1#2{% #1 and #2 is dummy
+ \def\@lisp@tmp@local@iii{\@tlabel@nil{}}%
+ \ifx\@lisp@tmp@local@ii\@empty%if there is no argument
+ \let\@@next\@@apply@create@env@bind@rest@create@cell@fin
+ \else
+ \let\@@next\@@apply@create@env@bind@rest@create@cell@alloc
+ \fi
+ \expandafter\@@next\@lisp@tmp@local@ii\relax\relax}
+\def\@@apply@create@env@bind@rest@create@cell@fin{%
+ \expandafter\@@apply@create@env@bind@rest@create@cell@fin@\@lisp@tmp@local@i}
+\def\@@apply@create@env@bind@rest@create@cell@fin@#1#2{%
+ \expandafter\@@apply@create@env@bind@rest@create@cell@fin@@
+ \expandafter{\@lisp@tmp@local@iii}#1#2}
+\def\@@apply@create@env@bind@rest@create@cell@fin@@#1#2#3{%
+ \expandafter\def\expandafter#2\expandafter{#2#3{#1}}}
+\def\@@apply@create@env@bind@rest@create@cell@alloc#1#2#3#4{%
+ \@lisp@gc@alloc\@lisp@tmp@local@iv % CAR
+ \expandafter\gdef\@lisp@tmp@local@iv{#1{#2}}%
+ \@lisp@gc@alloc\@lisp@tmp@local@v % CDR
+ \expandafter\global\expandafter\let\@lisp@tmp@local@v\@lisp@tmp@local@iii
+ \toks0\expandafter{\@lisp@tmp@local@iv}%
+ \toks2\expandafter{\@lisp@tmp@local@v}%
+ \edef\@lisp@tmp@local@iii{\noexpand\@tlabel@cons{\the\toks0 \the\toks2}}%
+ \ifx#3\relax
+ \let\@@next\@@apply@create@env@bind@rest@create@cell@fin
\else
- \expandafter\def\expandafter#1\expandafter{#1#4{#2{#3}}}%
- \fi}
-\def\@@next@args#1#2\@{\def\@@next@args@{#2}}
+ \let\@@next\@@apply@create@env@bind@rest@create@cell@alloc
+ \fi
+ \@@next#3{#4}}
+% koko, @apply to @@apply wo irekaeru beki?
\def\@@apply@macro#1#2\@#3#4{\@@apply@macro@next#1#2\@{#3}#4}
\def\@@apply@macro@next#1#2#3#4#5\@#6#7{%
\def\@temp@env{}%
+ \@lisp@gc@save@objects@local{#5}% pin arguments
\@@apply@create@env\@temp@env#1#5\relax\relax
- \expandafter\gdef\expandafter\@@tco\expandafter{%
- \expandafter\@@eval@envcs\expandafter{\@temp@env#2}#3{#4}#7%
- \expandafter\@eval#7{#6}#7}%
+ \begingroup
+ \toks0\expandafter{\@temp@env#2}%
+ \toks1{#3{#4}#7}%
+ \toks2{#7{#6}#7}%
+ \xdef\@@tco{%
+ \noexpand\@@eval@envcs{\the\toks0}\the\toks1
+ \noexpand\expandafter\noexpand\@eval\the\toks2}%
+ \endgroup
\aftergroup\@@tco}
\let\@apply@macro\@@apply@macro
\def\@apply@macroexpand#1#2#3\@#4#5{% cont, args, \@ env, reg
\let\@@apply@macro@next\@@apply@macro@next@expand@only
+ \@lisp@eval@save@envtrue
\@eval#2{#3}{#4}#5%
+ \expandafter\@lisp@gc@save@objects@local\expandafter{#5}% pin tmp result
\expandafter\@eval#5{#4}#5}
\def\@@apply@macro@next@expand@only#1#2#3#4#5\@#6#7{%
\def\@temp@env{}%
+ \@lisp@gc@save@objects@local{#5}% pin args
\@@apply@create@env\@temp@env#1#5\relax\relax
- \expandafter\gdef\expandafter\@@tco\expandafter{%
- \expandafter\@@eval@envcs\expandafter{\@temp@env#2}#3{#4}#7%
- \expandafter\@eval@if@macro#7{#6}#7}%
+ \begingroup
+ \toks0\expandafter{\@temp@env#2}%
+ \toks1{#3{#4}#7}%
+ \toks2\expandafter{#7{#6}#7}%
+ \xdef\@@tco{%
+ \begingroup
+ \noexpand\@lisp@eval@save@envtrue
+ \noexpand\@@eval@envcs{\the\toks0}\the\toks1
+ \noexpand\@lisp@eval@save@envtrue
+ \noexpand\@eval@if@macro\the\toks2
+ \endgroup}%
+ \endgroup
\aftergroup\@@tco}
\def\@eval@if@macro#1#2#3#4{%
\ifx#1\@tlabel@cons\@eval@if@macro@#2{#3}#4\fi}
@@ -581,17 +773,20 @@
\ifx#1\@tlabel@macro\@eval\@tlabel@cons{#3#4}{#5}#6\else\gdef#6{\@tlabel@cons{#3#4}}\fi}
-
\def\@apply@begin#1#2\@#3#4{%
\@apply@begin@next#4{#3}#2\relax\relax}
\def\@apply@begin@next#1#2#3#4#5#6{%
+ \@lisp@gc@save@env@local{#2}% pin environment
\ifx#5\relax
\let\@@next\@apply@begin@final
\else
\let\@@next\@apply@begin@cont
\fi\@@next{#1}{#2}{#3}{#4}{#5}{#6}}
\def\@apply@begin@final#1#2#3#4#5#6{%
- \gdef\@@tco{\@eval#3{#4}{#2}#1}\aftergroup\@@tco}
+ \gdef\@@tco{%
+ \@lisp@eval@save@envtrue
+ \@eval#3{#4}{#2}#1}%
+ \aftergroup\@@tco}
\def\@apply@begin@cont#1#2#3#4#5#6{%
\@eval#3{#4}{#2}#1%
\expandafter\expandafter\expandafter\ifx
@@ -608,6 +803,7 @@
\newcount\c@lisp@continuation@label
\def\@apply@callocc#1#2#3\@#4#5{%
\advance\c@lisp@continuation@label 1
+ \@lisp@gc@save@env@local{#4}%
\@eval#2{#3}{#4}#5%
\expandafter\expandafter\expandafter\ifx
\expandafter\@@eval@get@typelabel#5\@tlabel@exception
@@ -643,6 +839,7 @@
\def\@apply@callocc@hook#1#2{\gdef#1{#2}}
\def\@apply@continuation#1#2#3\@#4#5{%
+ \@lisp@gc@save@env@local{#4}%
\@eval#2{#3}{#4}#5%
\expandafter\expandafter\expandafter\ifx
\expandafter\@@eval@get@typelabel#5\@tlabel@exception
@@ -655,24 +852,67 @@
\toks0\expandafter{#5}%
\xdef#5{\noexpand\@tlabel@exception{{#1}{\the\toks0}}}}
+% check #function's arguments
+%#1 #args(*, +, or n), #2 function body
+%#3 reg, #4 args
+\newcount\@lisp@func@heck@args@count
+\def\@lisp@func@check@args#1#2#3#4\relax{%
+ \@lisp@func@heck@args@count0
+ \@lisp@func@check@args@#4\relax\relax
+ \def\@@next@true{#2#3#4\relax}%
+ \def\@@next@few{\gdef#3{%
+ \@tlabel@exception{{-1}%
+ {\@tlabel@string{too few arguments}}}}}%
+ \def\@@next@many{\gdef#3{%
+ \@tlabel@exception{{-1}%
+ {\@tlabel@string{too many arguments}}}}}%
+ \ifx#1*%
+ \let\@@next\@@next@true
+ \else\ifx#1+%
+ \ifnum\@lisp@func@heck@args@count>0
+ \let\@@next\@@next@true
+ \else
+ \let\@@next\@@next@few
+ \fi
+ \else
+ \ifnum\@lisp@func@heck@args@count=#1
+ \let\@@next\@@next@true
+ \else\ifnum\@lisp@func@heck@args@count>#1
+ \let\@@next\@@next@many
+ \else
+ \let\@@next\@@next@few
+ \fi\fi
+ \fi\fi
+ \@@next}
+\def\@lisp@func@check@args@#1#2{%
+ \ifx#1\relax
+ \let\@@next\relax
+ \else
+ \advance\@lisp@func@heck@args@count1
+ \let\@@next\@lisp@func@check@args@
+ \fi
+ \@@next}
+
+% select GC engine
+\ifcase\@lisp@gc@style
+ \expandafter\RequirePackage\expandafter[\@lisp@opt@gc]{lisp-simple-alloc} \or
+ \expandafter\RequirePackage\expandafter[\@lisp@opt@gc]{lisp-gc} \fi
+\@lisp@gc@init
% reader
-\input{lisp-read.sty}
+\RequirePackage{lisp-read}
%arithmetical functions
-\input{lisp-arith.sty}
+\RequirePackage{lisp-arith}
%string manipulation
-\input{lisp-string.sty}
+\RequirePackage{lisp-string}
% connection to TeX world
-\input{lisp-latexutil.sty}
-
-% type cast functions
-\input{lisp-cast.sty}
+\RequirePackage{lisp-latexutil}
% other primitive functions
-\input{lisp-prim.sty}
+\RequirePackage{lisp-prim}
% functions defined by LISP codes
-\input{lisp-util.sty}
+\RequirePackage{lisp-util}
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-prim.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-prim.sty
index 7645135a88b..4f921612d83 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-prim.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-prim.sty
@@ -1,23 +1,23 @@
%% Syntax functions
-\addassoc\@globalenv\quote{\@tlabel@quote{}}%
-\addassoc\@globalenv\lambda{\@tlabel@lambda{}}
-\addassoc\@globalenv\define{\@tlabel@define{}}
-\addassoc\@globalenv\lispif{\@tlabel@if{}}
-\addassoc\@globalenv\defmacro{\@tlabel@defmacro{}}
-\addassoc\@globalenv\begin{\@tlabel@begin{}}
-\addassoc\@globalenv\defineM{\@tlabel@mdefine{}}
-\addassoc\@globalenv\setB{\@tlabel@setb{}}
-\addassoc\@globalenv\@let{\@tlabel@@let{}}
-\addassoc\@globalenv\@mlet{\@tlabel@@mlet{}}
-\addassoc\@globalenv\macroexpand{\@tlabel@macroexpand{}}
-\addassoc\@globalenv\callOCC{\@tlabel@callocc{}}
-
-\addassoc\@globalenv\car{\@tlabel@func{\@get@car}}
-\addassoc\@globalenv\cdr{\@tlabel@func{\@get@cdr}}
-\addassoc\@globalenv\cons{\@tlabel@func{\@make@cons}}
+\@lisp@env@add@global\quote{\@tlabel@quote{}}%
+\@lisp@env@add@global\lambda{\@tlabel@lambda{}}
+\@lisp@env@add@global\define{\@tlabel@define{}}
+\@lisp@env@add@global\lispif{\@tlabel@if{}}
+\@lisp@env@add@global\defmacro{\@tlabel@defmacro{}}
+\@lisp@env@add@global\begin{\@tlabel@begin{}}
+\@lisp@env@add@global\defineM{\@tlabel@mdefine{}}
+\@lisp@env@add@global\setB{\@tlabel@setb{}}
+\@lisp@env@add@global\@let{\@tlabel@@let{}}
+\@lisp@env@add@global\@mlet{\@tlabel@@mlet{}}
+\@lisp@env@add@global\macroexpand{\@tlabel@macroexpand{}}
+\@lisp@env@add@global\callOCC{\@tlabel@callocc{}}
+
+\@lisp@env@add@global\car{\@tlabel@func{\@lisp@func@check@args{1}{\@lisp@perform@car}}}
+\@lisp@env@add@global\cdr{\@tlabel@func{\@lisp@func@check@args{1}{\@lisp@perform@cdr}}}
+\@lisp@env@add@global\cons{\@tlabel@func{\@lisp@func@check@args{2}{\@lisp@perform@cons}}}
\newcount\@temp@count
-\addassoc\@globalenv\length{\@tlabel@func{\@lisp@length}}
+\@lisp@env@add@global\length{\@tlabel@func{\@lisp@func@check@args{1}{\@lisp@length}}}
\def\@lisp@length{\@temp@count0\relax\@lisp@length@}
\def\@lisp@length@#1#2#3{%
\ifx#2\@tlabel@nil
@@ -34,7 +34,7 @@
\def\@@lisp@length#1#2#3{\expandafter\@lisp@length@\expandafter#3#2}
%equality
-\addassoc\@globalenv\={\@tlabel@func{\@lisp@equal}}
+\@lisp@env@add@global\={\@tlabel@func{\@lisp@func@check@args{2}{\@lisp@equal}}}
\def\@lisp@equal#1#2#3#4#5{%
\gdef#1{\@tlabel@bool{f}}%
\ifx#2#4%
@@ -44,7 +44,7 @@
\fi}
% printing function
-\addassoc\@globalenv\print{\@tlabel@func{\@tex@print}}
+\@lisp@env@add@global\print{\@tlabel@func{\@lisp@func@check@args{1}{\@tex@print}}}
\def\@tex@print#1{\gdef#1{\@tlabel@nil{}}\@tex@print@}
\def\@tex@print@#1#2{%
\ifx#1\@tlabel@int
@@ -84,7 +84,7 @@
-\addassoc\@globalenv\texprint{\@tlabel@func{\@tex@texprint}}
+\@lisp@env@add@global\texprint{\@tlabel@func{\@lisp@func@check@args{1}{\@tex@texprint}}}
\def\@tex@texprint#1#2#3{%
\gdef#1{\@tlabel@nil{}}\@@tex@texprint#2{#3}}
\def\@@tex@texprint#1#2{%
@@ -96,7 +96,7 @@
\@add@to@write@buffer\@temp@write@buffer{INNER TOKEN}%
\fi\fi}
-\addassoc\@globalenv\stdprint{\@tlabel@func{\@tex@stdprint}}
+\@lisp@env@add@global\stdprint{\@tlabel@func{\@lisp@func@check@args{1}{\@tex@stdprint}}}
\def\@tex@stdprint#1#2#3{%
\gdef#1{\@tlabel@nil{}}%
\let\@save@write@buffer\@temp@write@buffer
@@ -109,23 +109,23 @@
% Type predicates
\def\@type@pred@add#1{\expandafter\@@type@pred@add\expandafter#1}
-\def\@@type@pred@add#1#2{\addassoc\@globalenv#1{\@tlabel@func{#2}}}
+\def\@@type@pred@add#1#2{\@lisp@env@add@global#1{\@tlabel@func{\@lisp@func@check@args{1}{#2}}}}
\def\@type@pred@define#1{\expandafter\@@type@pred@define\expandafter#1}
\def\@@type@pred@define#1#2{%
\def#1##1##2##3{\ifx##2#2\gdef##1{\@tlabel@bool{t}}\else\gdef##1{\@tlabel@bool{f}}\fi}}
-\def\@type@addassoc{\addassoc\@globalenv}
-\@for\@type:=\@defined@datatype\do{%
- \expandafter\@type@pred@add\csname\@type Q\endcsname\csname @type@\@type\endcsname
- \expandafter\@type@pred@define\csname @type@\@type\endcsname\csname @tlabel@\@type\endcsname}
+\@for\@lisp@on@tex@type:=\@defined@datatype\do{%
+ \expandafter\@type@pred@add\csname\@lisp@on@tex@type Q\endcsname
+ \csname @type@\@lisp@on@tex@type\endcsname
+ \expandafter\@type@pred@define\csname @type@\@lisp@on@tex@type\endcsname\csname @tlabel@\@lisp@on@tex@type\endcsname}
-\addassoc\@globalenv\pairQ{\@tlabel@func{\@type@cons}}
-\addassoc\@globalenv\booleanQ{\@tlabel@func{\@type@bool}}
+\@lisp@env@add@global\pairQ{\@tlabel@func{\@type@cons}}
+\@lisp@env@add@global\booleanQ{\@tlabel@func{\@type@bool}}
% eval , apply
-\addassoc\@globalenv\eval{\@tlabel@envfunc{\@extern@eval}}
+\@lisp@env@add@global\eval{\@tlabel@envfunc{\@extern@eval}}
\def\@extern@eval#1#2#3#4{\@eval#3{#4}{#2}#1}
-\addassoc\@globalenv\apply{\@tlabel@envfunc{\@extern@apply}}
+\@lisp@env@add@global\apply{\@tlabel@envfunc{\@extern@apply}}
\def\@extern@apply#1#2#3#4#5#6{% reg, env, labelfun, contfun, labellist, contlist
\def\@lisp@apply@temp{}% init
\@flatten@args#5{#6}\@lisp@apply@temp
@@ -134,13 +134,43 @@
{\expandafter\@@select@@apply#2{#3}#1\@{#4}#5}}
% values
-%\addassoc\@globalenv\values{\@tlabel@func{\@lisp@multivalues}}
+%\@lisp@env@add@global\values{\@tlabel@func{\@lisp@multivalues}}
%\def\@lisp@multivalues#1#2\relax{\gdef#1{#2}}
% read
-\addassoc\@globalenv\read{\@tlabel@func{\@lisp@read@stdin}}
+\@lisp@env@add@global\read{\@tlabel@func{\@lisp@func@check@args{0}{\@lisp@read@stdin}}}
\def\@lisp@read@stdin#1{%
\read-1 to#1%
\def\@lisp@read@stdin@callback##1##2{%
\gdef#1{##1{##2}}}%
\expandafter\@lispread\expandafter\@lisp@read@stdin@callback#1}
+
+% create a list
+\@lisp@env@add@global\list{\@tlabel@func{\@lisp@func@check@args{*}{\@lisp@prim@list@pre}}}
+\def\@lisp@prim@list@pre#1{\gdef#1{}\@lisp@prim@list#1}
+\def\@lisp@prim@list#1#2#3{%
+ \ifx#2\relax
+ \let\@@next\@lisp@prim@list@fin
+ \else
+ \let\@@next\@lisp@prim@list@add
+ \fi\@@next#1#2{#3}}
+\def\@lisp@prim@list@add#1#2#3{%
+ \begingroup
+ \toks0\expandafter{#1}%
+ \toks1{#2{#3}}%
+ \xdef#1{\the\toks1 \the\toks0}%reverse arguments
+ \endgroup
+ \@lisp@prim@list#1}
+\def\@lisp@prim@list@fin#1#2#3{\expandafter\@lisp@prim@list@fin@\expandafter#1#1\relax\relax}
+\def\@lisp@prim@list@fin@#1{%
+ \gdef#1{\@tlabel@nil{}}%
+ \@lisp@prim@list@fin@@#1}
+\def\@lisp@prim@list@fin@@#1#2#3{%
+ \ifx#2\relax
+ \def\@@next##1##2##3{}%
+ \else
+ \let\@@next\@lisp@prim@list@fin@@@
+ \fi
+ \@@next#1#2{#3}}
+\def\@lisp@prim@list@fin@@@#1#2#3{\expandafter\@lisp@prim@list@fin@@@@#1#2{#3}#1}
+\def\@lisp@prim@list@fin@@@@#1#2#3#4#5{\@lisp@perform@cons#5#3{#4}#1{#2}\@lisp@prim@list@fin@@#5}
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-read.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-read.sty
index 5a6f66cf00b..bcfb7fd4fa1 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-read.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-read.sty
@@ -27,7 +27,7 @@
\def\@@next{\@lispread@symbol#1#2}% [Branch 2-2] Symbol
\fi
\else\if\noexpand#2'% [Branch 3] String
- \def\@@next{\@lispread@string#1}%
+ \def\@@next{\@lispread@string#1\@lispread@string@dummy}%
\else\if\noexpand#2/% [Branch 4] Boolean
\def\@@next{\@lispread@bool#1}%
\else\if\noexpand#2:% [Branch 5] Integer
@@ -46,8 +46,9 @@
\def\@lispread@symbol#1#2{%
\endgroup#1\@tlabel@symbol{#2}}
%% String
+\def\@lispread@string@dummy{} % to avoid consuming group
\def\@lispread@string#1#2'{%
- \endgroup#1\@tlabel@string{#2}}
+ \endgroup\expandafter#1\expandafter\@tlabel@string\expandafter{#2}}
%% Boolean
\def\@lispread@bool#1#2{%
\endgroup#1\@tlabel@bool{#2}}
@@ -106,24 +107,16 @@
\fi\@@next}
\def\@lispread@cell@cdr#1{%
\def\@lispread@cdr@reg##1##2{%
- \expandafter\@read@malloc\expandafter\@reg@tmp\@reg@lispread@car##1{##2}%
+ \expandafter\@lisp@perform@cons@local\expandafter\@reg@tmp\@reg@lispread@car##1{##2}%
\expandafter\endgroup\expandafter#1\@reg@tmp}%
\@lispread\@lispread@cdr@reg}
\def\@lispread@fin#1#2{%
\if\noexpand#2)%
\def\@@next{%
- \expandafter\expandafter\expandafter\@read@malloc
+ \expandafter\expandafter\expandafter\@lisp@perform@cons@local
\expandafter\expandafter\expandafter\@reg@tmp
\expandafter\@reg@lispread@car\@reg@lispread@cdr
\expandafter\endgroup\expandafter#1\@reg@tmp}%
\else
\def\@@next{\errmessage{LISP on teX [read]: missing )}}%
\fi\@@next}
-\def\@read@malloc#1#2#3#4#5{%
- \expandafter\gdef\csname car\the\@malloc\endcsname{#2{#3}}%
- \expandafter\gdef\csname cdr\the\@malloc\endcsname{#4{#5}}%
- \expandafter\@@read@malloc\expandafter#1\csname car\the\@malloc\endcsname\csname cdr\the\@malloc\endcsname}
-\def\@@read@malloc#1#2{\expandafter\@@@read@malloc\expandafter#1\expandafter#2}
-\def\@@@read@malloc#1#2#3{%
- \global\advance\@malloc1
- \def#1{\@tlabel@cons{#2#3}}} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-simple-alloc.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-simple-alloc.sty
new file mode 100644
index 00000000000..6213d0cb5e3
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-simple-alloc.sty
@@ -0,0 +1,32 @@
+\newcount\@lisp@gc@simple@count
+
+% gc initializer (called by lisp-on-tex.sty)
+\def\@lisp@gc@init{\@lisp@gc@simple@count=0\relax}
+
+% allocator
+% The allocator define #1 to allocated the control sequence
+\def\@lisp@gc@alloc#1{%
+ \expandafter\def\expandafter#1\expandafter{%
+ \csname @lisp@gc@memory\the\@lisp@gc@simple@count\endcsname}%
+ \global\advance\@lisp@gc@simple@count1\relax}
+
+% GC main routine. The routine is called by the allocator.
+% If you want to call GC manually, you can do it.
+% In simple mode, this does not affects.
+\def\@lisp@gc@perform{}
+
+% pinning a object on global.
+% In simple mode, this does not affects.
+\def\@lisp@gc@pinning#1#2{}
+
+% pinning objects on local.
+% In simple mode, this does not affects.
+\def\@lisp@gc@save@objects@local#1{}
+
+% pinning memories on local.
+% In simple mode, this does not affects.
+\def\@lisp@gc@save@memory@local#1{}
+
+% pinning environmnt on local.
+% In simple mode, this does not affects.
+\def\@lisp@gc@save@env@local#1{} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-string.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-string.sty
index 87345706583..9c0c011a2c3 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-string.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-string.sty
@@ -1,6 +1,6 @@
%% CONCAT : string -> string -> string
%% (\concat str1 str2) => str1 ++ str2
-\addassoc\@globalenv\concat{\@tlabel@func{\def\@temp@str{}\@str@concat}}
+\@lisp@env@add@global\concat{\@tlabel@func{\@lisp@func@check@args{+}{\def\@temp@str{}\@str@concat}}}
\def\@str@concat#1#2#3{%
\let\@@next@str\relax
\ifx#2\@tlabel@string
@@ -20,20 +20,20 @@
%% INT2STRING : int -> string
%% (\intTOstring i) -> 'i'
-\addassoc\@globalenv\intTOstring{\@tlabel@func{\@conv@intTOstr}}
+\@lisp@env@add@global\intTOstring{\@tlabel@func{\@lisp@func@check@args{1}{\@conv@intTOstr}}}
\def\@conv@intTOstr#1\@tlabel@int#2{\gdef#1{\@tlabel@string{#2}}}
%% IMMEDIATEWRITE : () -> ()
%% It outputs the output buffer immediately.
%% It cause error if the buffer is incomplete.
-\addassoc\@globalenv\immediatewrite{\@tlabel@func{\@immediate@write}}
+\@lisp@env@add@global\immediatewrite{\@tlabel@func{\@lisp@func@check@args{0}{\@immediate@write}}}
\def\@immediate@write#1{%
\gdef#1{\@tlabel@nil{}}%
\@temp@write@buffer\gdef\@temp@write@buffer{}}
%% GROUP : string -> string
%% (\group str) -> '{str}'
-\addassoc\@globalenv\group{\@tlabel@func{\@text@group}}
+\@lisp@env@add@global\group{\@tlabel@func{\@lisp@func@check@args{1}{\@text@group}}}
\def\@text@group#1#2#3{%
\ifx#2\@tlabel@string
\gdef#1{\@tlabel@string{{#3}}}%
@@ -44,7 +44,7 @@
%% UNGROUP : string -> string
%% (\group '{str}') -> 'str'
-\addassoc\@globalenv\ungroup{\@tlabel@func{\@text@ungroup}}
+\@lisp@env@add@global\ungroup{\@tlabel@func{\@lisp@func@check@args{1}{\@text@ungroup}}}
\def\@text@ungroup#1#2#3{%
\ifx#2\@tlabel@string
\@@text@ungroup#1#3\@@end
@@ -62,7 +62,7 @@
%% FGETS : () -> string
%% (\fgets) -> read tokens from standard-in
-\addassoc\@globalenv\fgets{\@tlabel@func{\@text@fgets}}
+\@lisp@env@add@global\fgets{\@tlabel@func{\@lisp@func@check@args{0}{\@text@fgets}}}
\def\@text@fgets#1{%
\endlinechar=-1
\read-1to#1%
@@ -70,10 +70,7 @@
%% EXPAND : string -> string
%% (\expand '<token>') -> '<token+>' where <token+> is expanded tokens of <token>
-\addassoc\@globalenv\expand{\@tlabel@func{\@lot@text@expand}}
+\@lisp@env@add@global\expand{\@tlabel@func{\@lisp@func@check@args{1}{\@lot@text@expand}}}
\def\@lot@text@expand#1\@tlabel@string#2{%
\edef\@temp@i{#2}%
\xdef#1{\noexpand\@tlabel@string{\@temp@i}}}
-
-
-
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-util.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-util.sty
index 337ef5f0435..17681f7f547 100644
--- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-util.sty
+++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-util.sty
@@ -31,8 +31,6 @@
(\lispif (\= () \l)
/f
(\lispif (\car \l) /t (\apply \or (\cdr \l))))))
-%% list
-(\define \list (\lambda \x \x))
%% let bindings
(\defmacro \let
(\lambda (\binds \body)