LISP on T EX Comparison A LISP Interpreter Written Using T EX - - PowerPoint PPT Presentation

lisp on t ex
SMART_READER_LITE
LIVE PREVIEW

LISP on T EX Comparison A LISP Interpreter Written Using T EX - - PowerPoint PPT Presentation

LISP on T EX S. HAKUTA Introduction Goal and Mean LISP on TeX LISP on T EX Comparison A LISP Interpreter Written Using T EX Macros Conclusion HAKUTA Shizuya The 34th Annual Meeting of the TeX Users Group, 2013 Background LISP on T EX


slide-1
SLIDE 1

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

LISP on T EX

A LISP Interpreter Written Using T EX Macros HAKUTA Shizuya The 34th Annual Meeting of the TeX Users Group, 2013

slide-2
SLIDE 2

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Background

Writing T EX macros is useful.

e.g. Calculating some small numeric expressions.

However, it is difficult for novice users. To improve, there are some researches that combine T EX and another programming language.

slide-3
SLIDE 3

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

T EX with Other Languages

Pakin[TUGboat ’03] showed four way to connect T EX and a foreign programing language;

1 using \write18 to call an outer processor,

python package (CTAN:macros/latex/contrib/python)

2 embedding an interpreter in a T

EX engine,

LuaT EX (CTAN:systems/luatex)

3 constructing macros that enable L A

T EX to communicate with an external interpreter,

PerlT EX (CTAN:macros/latex/conrtib/perltex)

4 creating a language processor with T

EX macros

L

AT

EX3 project created expl3: a new interface of T EX macros, but no ordinary language was implemented.

slide-4
SLIDE 4

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

The Goal and the Mean

Our goals are Implementing a language’s interpreter with T EX macros, and Comparing its performance with other approaches. We take two design choices;

1 Choosing LISP as a ordinary language, and 2 Creating the product as a LaTeX package.

slide-5
SLIDE 5

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

LISP on T EX

We name the our product LISP on T EX. It was already archived on CTAN and T EXLive.

macros/latex/contrib/lisp-on-tex

We constructed all parts of LISP on T EX with T EX macros;

parser, recognizing LISP expressions, evaluator, calculating a expression, and environment, mapping symbols to LISP objects.

The code is written with traditional TeX macros only, so it works in all L

A

T EX engines,

L

AT

EX, pdfL

A

T EX, LuaL

AT

EX, XeL

A

T EX, pL

A

T EX, . . .

slide-6
SLIDE 6

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Examples (1/2)

Source

The Preamble of the Slides \usepackage{lisp-on-tex} \lispinterp{ (\define \fact (\lambda (\n) (\lispif (\= \n :0) :1 (\* (\fact (\- \n :1)) \n))))}

Result

$10!=\lispinterp{(\texprint(\fact:10))}$

slide-7
SLIDE 7

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Examples (1/2)

Source

The Preamble of the Slides \usepackage{lisp-on-tex} \lispinterp{ (\define \fact (\lambda (\n) (\lispif (\= \n :0) :1 (\* (\fact (\- \n :1)) \n))))}

Result 10! = 3628800

slide-8
SLIDE 8

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Examples (1/2)

Source

The Preamble of the Slides \usepackage{lisp-on-tex} \lispinterp{ (\define \fact (\lambda (\n) (\lispif (\= \n :0) :1 (\* (\fact (\- \n :1)) \n))))}

Result 10! = 3628800

LISP codes were evaluated!

slide-9
SLIDE 9

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Examples (2/2)

slide-10
SLIDE 10

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Examples (2/2)

slide-11
SLIDE 11

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Memory Management Problems

LISP on T EX uses a lot of memory.

Yato showed that LISP on T EX stalls when using a lot of LISP

  • bjects1.

It is caused by spending a lot of control sequences. Building a garbage collection system is one of our future work.

1http://d.hatena.ne.jp/zrbabbler/20121116/1353068217

(Japanese Only)

slide-12
SLIDE 12

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Comparison to other approaches

We compared LISP on T EX and other approaches by three benchmarks. CPU Core i7 2.2GHz, 8GByte Memory, W32TeX tarai[sec] asterisks[sec] Mandelbrot[sec] LISP on T EX 13 1.6 × 102 2.1 × 104 PerlT EX 1.0 1.0 1.6 × 102 LuaT EX 0.45 0.55 7.6 T EX macros 0.24 0.22 1.2 × 102 expl3 1.1 1.0 5.7 × 103 It shows that LISP on T EX is too slow... :-(

It is caused by reading T EX tokens repeatedly. ⇒ We can make LISP on T EX faster with improving the code.

slide-13
SLIDE 13

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Conclusion

We implemented LISP on T EX, a LISP interpreter written only with T EX macros. It works well, but the product has problems about memory usage and speed.

slide-14
SLIDE 14

LISP on T EX

  • S. HAKUTA

Introduction Goal and Mean LISP on TeX Comparison Conclusion

Why LISP is Selected?

There are two reasons why we select LISP .

1 LISP is Turing complete, so it contains all essence of

programming languages.

2 Because LISP has simple syntax and semantics, we can

implement LISP easily.