summaryrefslogtreecommitdiffstats
path: root/2023/info/repl-after.md
blob: d2819d6814c876b3501e69e72d7ec9e75c175b4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
<!-- Automatically generated by emacsconf-publish-after-page -->


<a name="repl-mainVideo-transcript"></a>
# Transcript


[[!template new="1" text="""Intro""" start="00:00:00.000" video="mainVideo-repl" id="subtitle"]]

[[!template text="""Hi, my name is Eduardo Ochs""" start="00:00:00.000" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and the title of this talk is""" start="00:00:00.015" video="mainVideo-repl" id="subtitle"]]
[[!template text="""REPLs in Strange Places: Lua, LaTeX,""" start="00:00:05.020" video="mainVideo-repl" id="subtitle"]]
[[!template text="""LPeg, LPegRex, and TikZ.""" start="00:00:07.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I'm the author of an Emacs package called eev,""" start="00:00:10.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and this is a talk at the EmacsConf 2023,""" start="00:00:13.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is happening in December 2023 at the Internet.""" start="00:00:17.280" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Diagrams""" start="00:00:21.560" video="mainVideo-repl" id="subtitle"]]

[[!template text="""This is one of the examples of diagrams""" start="00:00:21.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that we are going to see.""" start="00:00:24.244" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me show how I generated it.""" start="00:00:25.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""One second, I have to use a smaller font here.""" start="00:00:28.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is a file called parse32.lua.""" start="00:00:34.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me go back to this block of tests again.""" start="00:00:39.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Now, if I run this,""" start="00:00:42.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we get these outputs here at the right.""" start="00:00:46.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Then in this line here,""" start="00:00:51.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it generates a PDF,""" start="00:00:53.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and if I type `F8` here,""" start="00:00:55.420" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it shows the PDF in the lower right window.""" start="00:00:57.780" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""eev""" start="00:01:03.320" video="mainVideo-repl" id="subtitle"]]

[[!template text="""Let me start by explaining briefly what is eev.""" start="00:01:03.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""First, it's something""" start="00:01:08.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that appeared by accident in the mid 90s.""" start="00:01:10.890" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I explained this story in my presentation at EmacsConf 2019.""" start="00:01:14.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It's an Emacs package that is part of ELPA.""" start="00:01:20.640" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It has at least 10 users.""" start="00:01:25.420" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Those are the ones that I know by name.""" start="00:01:28.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev means &quot;Emacs, execute verbosely&quot;.""" start="00:01:32.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev is something that treats eval-last-sexp""" start="00:01:36.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""as the central feature of Emacs.""" start="00:01:38.848" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev blurs the distinction between programmers and users,""" start="00:01:43.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and it replaces the slogan,""" start="00:01:47.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""&quot;users should not be forced to see Lisp&quot;""" start="00:01:49.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""(that is something that Richard Stallman told me once),""" start="00:01:52.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""by &quot;users should see Lisp instead of buttons,&quot;""" start="00:01:55.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and &quot;new users should see Lisp in the first five minutes.&quot;""" start="00:01:59.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I'm going to show some examples of that soon.""" start="00:02:03.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev uses code in the comments a lot""" start="00:02:08.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and also tests in comments.""" start="00:02:11.566" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I changed my way of presenting it,""" start="00:02:14.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and it became very REPL-centric""" start="00:02:16.782" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the last few years, in the sense that""" start="00:02:19.191" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I start by explaining its main features""" start="00:02:22.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""by its support for REPLs.""" start="00:02:26.461" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev supposes that we want to keep""" start="00:02:29.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""executable notes of everything.""" start="00:02:32.079" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I'm also going to show examples of this in a second.""" start="00:02:34.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev has lots of videos for people who hate videos,""" start="00:02:37.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and it tries to do everything""" start="00:02:42.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with very little magic and without black boxes.""" start="00:02:44.271" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I'm going to explain many of these things very soon.""" start="00:02:47.640" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Another figure""" start="00:02:51.360" video="mainVideo-repl" id="subtitle"]]

[[!template text="""This is a figure that I'm going to show in detail soon""" start="00:02:51.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is about something important about Lua.""" start="00:02:58.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Oops, the font is very bad now,""" start="00:03:01.640" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so let me change the font.""" start="00:03:03.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The figure is this one.""" start="00:03:05.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""What most people do when they visit a file""" start="00:03:09.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with something interesting in it,""" start="00:03:12.936" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is that they just go there and they set a bookmark there,""" start="00:03:15.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""or they put the position in the register.""" start="00:03:18.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""But I prefer to keep links""" start="00:03:22.640" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to everything that is interesting""" start="00:03:29.782" video="mainVideo-repl" id="subtitle"]]
[[!template text="""as an Elisp hyperlink.""" start="00:03:30.222" video="mainVideo-repl" id="subtitle"]]
[[!template text="""For example, this is an Elisp hyperlink to the file""" start="00:03:30.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that goes to this anchor here,""" start="00:03:34.237" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and to this string after this anchor.""" start="00:03:36.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is a variant that opens that file""" start="00:03:39.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the window at the right here,""" start="00:03:43.389" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and this is a sexp that changes the font.""" start="00:03:46.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I have a command with a very short name that does that,""" start="00:03:53.640" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but I prefer to keep that as a one-liner.""" start="00:03:57.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""About the videos, we can see""" start="00:04:03.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the list of first-class videos of eev by executing this,""" start="00:04:04.282" video="mainVideo-repl" id="subtitle"]]
[[!template text="""`M-x find-1stclassvideos`,""" start="00:04:11.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""or by running this alias here, `M-x 1c`,""" start="00:04:14.191" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and then what we see is this.""" start="00:04:18.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The first sexp here regenerates this buffer,""" start="00:04:21.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so we can make a mess here and then run this,""" start="00:04:25.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and the original buffer is regenerated again in a clean way.""" start="00:04:29.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Each of these things here""" start="00:04:34.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""opens a buffer with information about a video.""" start="00:04:36.952" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me take a specific example here.""" start="00:04:41.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This video here is about one of the ancestors of this talk""" start="00:04:45.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is a library that I wrote""" start="00:04:50.279" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for creating diagrams in LaTeX""" start="00:04:52.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""using a package called [pict2e-lua] using REPLs.""" start="00:04:56.907" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, the thing is that if we run a sexp like this one""" start="00:05:03.000" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and we don't have a local copy of the video,""" start="00:05:10.029" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev will try to load the local copy""" start="00:05:16.315" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and instead of doing that by asking something""" start="00:05:19.582" video="mainVideo-repl" id="subtitle"]]
[[!template text="""like &quot;do you want me to download the local copy&quot;""" start="00:05:20.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""blah, blah, blah, it simply opens a buffer like this.""" start="00:05:25.382" video="mainVideo-repl" id="subtitle"]]
[[!template text="""And if we don't have a local copy yet,""" start="00:05:29.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it will open a buffer like this one,""" start="00:05:35.515" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in which these things here in comments""" start="00:05:37.221" video="mainVideo-repl" id="subtitle"]]
[[!template text="""are links to the documentation.""" start="00:05:40.031" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This thing here explains the idea""" start="00:05:42.679" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of local copies of files from the internet.""" start="00:05:45.781" video="mainVideo-repl" id="subtitle"]]
[[!template text="""There are more details here and here,""" start="00:05:50.279" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and this is a script that we can execute line by line.""" start="00:05:54.121" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So instead of this script being hidden behind the button""" start="00:05:59.580" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that we just press after a question""" start="00:06:04.277" video="mainVideo-repl" id="subtitle"]]
[[!template text="""like &quot;do you want me to do something,&quot; blah, blah, blah,""" start="00:06:07.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""&quot;yes or no?&quot;, the script is visible here""" start="00:06:10.709" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and we can execute it step by step.""" start="00:06:13.229" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It creates a terminal with a shell here in the right window""" start="00:06:15.380" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and when we type `F8` in these lines here,""" start="00:06:22.458" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the lines are sent to this line.""" start="00:06:26.989" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So this is going to download a copy of the video,""" start="00:06:30.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the wget says that I already have a copy of the video""" start="00:06:33.843" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and its subtitles and so on.""" start="00:06:38.135" video="mainVideo-repl" id="subtitle"]]
[[!template text="""And after getting a copy of the video""" start="00:06:40.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we can run this exp here and it displays the video.""" start="00:06:45.740" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I said that eev has lots of videos""" start="00:06:52.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for people who hate videos.""" start="00:06:55.487" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The idea is that very few people""" start="00:06:57.436" video="mainVideo-repl" id="subtitle"]]
[[!template text="""are going to watch the videos in real time.""" start="00:07:00.047" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Most of the people that I know, or most of the people""" start="00:07:03.082" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that are interested in eev in some way,""" start="00:07:07.643" video="mainVideo-repl" id="subtitle"]]
[[!template text="""they are going to watch just small sections of the video.""" start="00:07:10.791" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Most of the time, they are just going to""" start="00:07:14.321" video="mainVideo-repl" id="subtitle"]]
[[!template text="""read the subtitles of the video.""" start="00:07:17.575" video="mainVideo-repl" id="subtitle"]]
[[!template text="""For each one of the videos""" start="00:07:19.940" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we have a page about the video...""" start="00:07:22.532" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me see if I have internet here...""" start="00:07:25.296" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is a page. Usually these pages""" start="00:07:29.674" video="mainVideo-repl" id="subtitle"]]
[[!template text="""have a link to another page,""" start="00:07:34.902" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the page that has all the subtitles of the video,""" start="00:07:38.428" video="mainVideo-repl" id="subtitle"]]
[[!template text="""wherever. In this one, it's not so visible.""" start="00:07:43.891" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, there are several ways of accessing""" start="00:07:48.588" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the subtitles of the video.""" start="00:07:52.002" video="mainVideo-repl" id="subtitle"]]
[[!template text="""One of the ways is by running this sexp here""" start="00:07:53.964" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that opens a file in Lua.""" start="00:07:58.633" video="mainVideo-repl" id="subtitle"]]
[[!template text="""That is what I use to generate the subtitles.""" start="00:08:01.065" video="mainVideo-repl" id="subtitle"]]
[[!template text="""By the way, each one of these things here""" start="00:08:05.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is hyperlinked to a position of the video.""" start="00:08:10.369" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If I type this, it goes to that position.""" start="00:08:14.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, let me go back.""" start="00:08:21.281" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So the tutorials of eev, the intros of eev""" start="00:08:24.580" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that start with `find-` and end with `-intro`,""" start="00:08:28.558" video="mainVideo-repl" id="subtitle"]]
[[!template text="""they have lots of blocks that say""" start="00:08:32.351" video="mainVideo-repl" id="subtitle"]]
[[!template text="""video links like this one.""" start="00:08:35.333" video="mainVideo-repl" id="subtitle"]]
[[!template text="""These blocks have links to positions in videos.""" start="00:08:37.613" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If we don't have a local copy of the video yet,""" start="00:08:41.973" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the thing shows us a script""" start="00:08:46.333" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that lets us download the local copy.""" start="00:08:49.016" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""eev-wconfig, magic, and black boxes""" start="00:08:52.560" video="mainVideo-repl" id="subtitle"]]

[[!template text="""I said that I was going to explain""" start="00:08:52.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""what I mean by magic and black boxes,""" start="00:08:57.441" video="mainVideo-repl" id="subtitle"]]
[[!template text="""this is something that I've been trying""" start="00:09:01.856" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to explain for a long time""" start="00:09:03.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I think that I got a very good explanation about that""" start="00:09:05.112" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in a video that I made about something called eev-wconfig""" start="00:09:08.762" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is a tool for configuring eev on Windows without magic,""" start="00:09:12.349" video="mainVideo-repl" id="subtitle"]]
[[!template text="""without buttons that do things,""" start="00:09:17.944" video="mainVideo-repl" id="subtitle"]]
[[!template text="""without explaining what they are doing.""" start="00:09:20.879" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is a part of the subtitles of the video.""" start="00:09:24.380" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me read that.""" start="00:09:28.079" video="mainVideo-repl" id="subtitle"]]
[[!template text="""eev-wconfig is an attempt to solve the problem""" start="00:09:29.446" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of how to install these things on Windows""" start="00:09:32.532" video="mainVideo-repl" id="subtitle"]]
[[!template text="""both without magic and with very little magic.""" start="00:09:35.350" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Remember this slogan: &quot;Any sufficiently advanced technology""" start="00:09:40.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is indistinguishable from magic.&quot;""" start="00:09:44.942" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here in this video I'm going to use the term magic""" start="00:09:47.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""as a shorthand for sufficiently advanced technology""" start="00:09:51.434" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is something that is complex and non obvious""" start="00:09:55.263" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and that is indistinguishable from magic""" start="00:09:58.945" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the sense of being almost impossible to understand.""" start="00:10:01.921" video="mainVideo-repl" id="subtitle"]]
[[!template text="""And I'm also going to use the term black box""" start="00:10:05.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""as a near synonym for magic""" start="00:10:09.273" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and sometimes the term black box is more convenient""" start="00:10:11.409" video="mainVideo-repl" id="subtitle"]]
[[!template text="""even though it's a bit longer,""" start="00:10:15.218" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it has more letters because when I use the term black box""" start="00:10:17.489" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it invites us to use expressions""" start="00:10:21.334" video="mainVideo-repl" id="subtitle"]]
[[!template text="""like opening the black box""" start="00:10:23.522" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I'm going to use that expression a lot.""" start="00:10:27.873" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Now let me try to explain what is. Sorry,""" start="00:10:34.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""let me change the font.""" start="00:10:40.900" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Lua""" start="00:10:44.240" video="mainVideo-repl" id="subtitle"]]

[[!template text="""What is Lua?""" start="00:10:44.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Lua is a minimalistic language""" start="00:10:45.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the sense of battery is not included.""" start="00:10:48.646" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It uses associative tables for most of its data structures.""" start="00:10:53.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It's so minimalistic""" start="00:10:57.988" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that the default print function""" start="00:11:00.875" video="mainVideo-repl" id="subtitle"]]
[[!template text="""when we create an associative table and we ask it to print--""" start="00:11:05.148" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we ask print to print an associative table--""" start="00:11:11.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it just prints the address of the table.""" start="00:11:14.915" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here are some examples. Here is a table""" start="00:11:17.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and when we ask to print it,""" start="00:11:20.903" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it just says that it's the table at this address here.""" start="00:11:23.297" video="mainVideo-repl" id="subtitle"]]
[[!template text="""One of the things that most people do""" start="00:11:28.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""when they start using Lua is that either""" start="00:11:30.894" video="mainVideo-repl" id="subtitle"]]
[[!template text="""they download a package with a print to printing function""" start="00:11:33.587" video="mainVideo-repl" id="subtitle"]]
[[!template text="""or they write their own print to printing functions.""" start="00:11:36.314" video="mainVideo-repl" id="subtitle"]]
[[!template text="""My own print to printing function""" start="00:11:39.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is called PP with upper case letters,""" start="00:11:41.976" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and it works like this.""" start="00:11:44.451" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It prints associative tables in a way like this.""" start="00:11:46.758" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It says that for the key 1,""" start="00:11:52.073" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the value associated to it is 2;""" start="00:11:54.126" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for the key 2, the value is 3;""" start="00:11:56.603" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and for the key 3, the value is 5.""" start="00:11:59.079" video="mainVideo-repl" id="subtitle"]]
[[!template text="""When I started using Lua, one of my favorite languages""" start="00:12:09.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""was also a language that used associative tables a lot.""" start="00:12:12.380" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It was called Icon. I had to write my own""" start="00:12:16.624" video="mainVideo-repl" id="subtitle"]]
[[!template text="""print to printing functions for Icon,""" start="00:12:20.340" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so I just had to port my print to printing functions to Lua.""" start="00:12:23.395" video="mainVideo-repl" id="subtitle"]]
[[!template text="""My first version looked something like this.""" start="00:12:29.426" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it just had some global functions. Lots of them actually.""" start="00:12:34.351" video="mainVideo-repl" id="subtitle"]]
[[!template text="""After a while, I rewrote it.""" start="00:12:40.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I rewrote it again and again and again.""" start="00:12:41.934" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is one of the versions""" start="00:12:44.504" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is not even the default at this point.""" start="00:12:48.398" video="mainVideo-repl" id="subtitle"]]
[[!template text="""`tos` is for to string. This is a demo.""" start="00:12:53.752" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It's very modular, so it's easy to replace parts of it""" start="00:12:57.703" video="mainVideo-repl" id="subtitle"]]
[[!template text="""or to toggle flags. This is an example.""" start="00:13:02.906" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If I try to print the table of methods for a certain class--""" start="00:13:06.568" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I only need a smaller font--it prints the table like this""" start="00:13:11.798" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with the names of the methods""" start="00:13:16.246" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and then links to the source code of the functions.""" start="00:13:18.511" video="mainVideo-repl" id="subtitle"]]
[[!template text="""These links only make sense in Emacs and in eev.""" start="00:13:22.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""When we run a link like this one,""" start="00:13:26.672" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it shows the source code and the window at the right.""" start="00:13:30.297" video="mainVideo-repl" id="subtitle"]]
[[!template text="""For some functions, the source code is three lines.""" start="00:13:34.014" video="mainVideo-repl" id="subtitle"]]
[[!template text="""For other ones, it's one line and whatever.""" start="00:13:38.648" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, let me go back.""" start="00:13:42.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Lua can be used in many different styles.""" start="00:13:44.150" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Most people hate other people's styles.""" start="00:13:47.491" video="mainVideo-repl" id="subtitle"]]
[[!template text="""When I started using it in the year 2000,""" start="00:13:52.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I learned most of the basic language in a single day.""" start="00:13:55.253" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It was very similar to things that I was already using.""" start="00:13:59.567" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Then I rewrote the mini language""" start="00:14:04.043" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that I was using to generate the HTML for my pages in Lua.""" start="00:14:08.389" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Actually, I had to rewrite it many times""" start="00:14:15.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but the first version I certainly did""" start="00:14:17.592" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in my first weeks or first months using Lua.""" start="00:14:21.368" video="mainVideo-repl" id="subtitle"]]
[[!template text="""In the beginning, I was just using it for writing programs""" start="00:14:25.740" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that either didn't take any input at all""" start="00:14:29.654" video="mainVideo-repl" id="subtitle"]]
[[!template text="""because the input was already in the source file,""" start="00:14:32.877" video="mainVideo-repl" id="subtitle"]]
[[!template text="""or that worked as a Unix function:""" start="00:14:36.728" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the Unix programs that would read files,""" start="00:14:39.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""process these files in some way, and output something.""" start="00:14:42.452" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I mentioned the basic language here,""" start="00:14:49.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I only learned how to use closures, meta tables,""" start="00:14:52.201" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and coroutines many years later.""" start="00:14:55.626" video="mainVideo-repl" id="subtitle"]]
[[!template text="""In the beginning when I started using Lua""" start="00:15:00.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it didn't have a package manager.""" start="00:15:02.589" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It appeared later. It is called luarocks.""" start="00:15:04.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It has had this package manager for several years.""" start="00:15:08.300" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Most of the rocks for luarocks are poorly documented""" start="00:15:13.180" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and hacker-unfriendly.""" start="00:15:17.243" video="mainVideo-repl" id="subtitle"]]
[[!template text="""You can't rely just on the documentation.""" start="00:15:18.898" video="mainVideo-repl" id="subtitle"]]
[[!template text="""You can't rely just on the source code,""" start="00:15:22.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""because--I mean, if you're a genius, of course you can,""" start="00:15:25.189" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but for people who are either""" start="00:15:28.707" video="mainVideo-repl" id="subtitle"]]
[[!template text="""lazy or dumb or whatever like me, or unfocused,""" start="00:15:31.545" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the source code is hard to understand""" start="00:15:35.896" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and hard to tinker with.""" start="00:15:39.491" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Some rocks are excellent.""" start="00:15:41.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The best rocks are well documented,""" start="00:15:43.761" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but they are hacker-unfriendly""" start="00:15:46.453" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the sense that I hope that I'll be able to explain soon.""" start="00:15:48.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The best rocks use local variables and meta tables a lot,""" start="00:15:53.640" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so if you are a beginner learning Lua""" start="00:15:59.467" video="mainVideo-repl" id="subtitle"]]
[[!template text="""you're not going to understand what their source codes do.""" start="00:16:02.906" video="mainVideo-repl" id="subtitle"]]
[[!template text="""They use lots of dirty tricks.""" start="00:16:08.246" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Object orientation in Lua""" start="00:16:10.960" video="mainVideo-repl" id="subtitle"]]

[[!template text="""Let me talk a bit about object orientation in Lua.""" start="00:16:10.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It can be done in many ways. The main book about Lua""" start="00:16:14.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""called Programming in Lua""" start="00:16:18.276" video="mainVideo-repl" id="subtitle"]]
[[!template text="""by one of the authors of the language""" start="00:16:20.141" video="mainVideo-repl" id="subtitle"]]
[[!template text="""called Roberto Ierusalimschy""" start="00:16:22.866" video="mainVideo-repl" id="subtitle"]]
[[!template text="""presents several ways of doing object orientation in Lua.""" start="00:16:24.730" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I hated all of these ways,""" start="00:16:28.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and also the ways that I tried from the rocks.""" start="00:16:31.387" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Then I wrote my own way""" start="00:16:36.057" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of doing object orientation in Lua.""" start="00:16:37.934" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It's very minimalistic. It's in this file here eoo.lua.""" start="00:16:40.348" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The main code is just these five lines here.""" start="00:16:45.654" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here's an example of how it works.""" start="00:16:49.899" video="mainVideo-repl" id="subtitle"]]
[[!template text="""We define a class vector with some meta methods.""" start="00:16:56.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This meta method here will tell Lua""" start="00:17:03.002" video="mainVideo-repl" id="subtitle"]]
[[!template text="""what to do when the user asks to add two vectors.""" start="00:17:06.295" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This one here tells Lua what to do""" start="00:17:10.868" video="mainVideo-repl" id="subtitle"]]
[[!template text="""when the user asks Lua to convert a vector to a string""" start="00:17:13.987" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and whatever. This one is something""" start="00:17:18.889" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that I'm going to explain in a second.""" start="00:17:22.008" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here we create a vector""" start="00:17:25.580" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with these coordinates 3 and 4.""" start="00:17:25.580" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here we create another vector.""" start="00:17:25.581" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If we print here,""" start="00:17:31.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""then Lua uses the function here in the `__tostring`.""" start="00:17:33.031" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If we add two vectors""" start="00:17:37.154" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it uses the function here in the `__add` meta method.""" start="00:17:38.908" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If we run the method `norm`,""" start="00:17:42.654" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it is defined here in the table index.""" start="00:17:45.045" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, even with this thing being so small,""" start="00:17:51.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I used to forget how it works all the time.""" start="00:17:57.676" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Actually, I always forget how things work,""" start="00:18:04.618" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I have to remember them somehow.""" start="00:18:08.201" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I have to have tricks for remembering,""" start="00:18:11.348" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and tricks for summarizing things and diagrams, and so on.""" start="00:18:14.921" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Every time that I forgot how this thing worked,""" start="00:18:19.770" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I went back to the source code""" start="00:18:23.310" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and then I looked at the diagrams,""" start="00:18:25.461" video="mainVideo-repl" id="subtitle"]]
[[!template text="""or, of course, the first time,""" start="00:18:28.149" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I had to draw the diagrams. I run the examples.""" start="00:18:30.995" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Of course, in the beginning""" start="00:18:33.801" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I thought that the code was clear.""" start="00:18:35.540" video="mainVideo-repl" id="subtitle"]]
[[!template text="""My examples were very brief.""" start="00:18:37.504" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So I had to rewrite the examples many times""" start="00:18:39.738" video="mainVideo-repl" id="subtitle"]]
[[!template text="""until they became let's say perfect.""" start="00:18:43.566" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I was saying that Lua can be used in many ways""" start="00:18:50.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and in my way of using Lua, in my favorite way,""" start="00:18:54.091" video="mainVideo-repl" id="subtitle"]]
[[!template text="""everything can be inspected and modified from REPLs""" start="00:18:58.404" video="mainVideo-repl" id="subtitle"]]
[[!template text="""like we can do in Emacs and in SmallTalk, sort of.""" start="00:19:03.076" video="mainVideo-repl" id="subtitle"]]
[[!template text="""In my favorite way of using Lua""" start="00:19:06.818" video="mainVideo-repl" id="subtitle"]]
[[!template text="""there's no security at all.""" start="00:19:09.437" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Everything can be changed at all times.""" start="00:19:11.532" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Of course, most people hate that.""" start="00:19:17.460" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""My init file""" start="00:19:19.823" video="mainVideo-repl" id="subtitle"]]

[[!template text="""My init file has lots of classes,""" start="00:19:19.823" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and by the way, instead of""" start="00:19:22.186" video="mainVideo-repl" id="subtitle"]]
[[!template text="""keeping many small files with many things,""" start="00:19:24.702" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I put lots of stuff in just one big init file.""" start="00:19:28.637" video="mainVideo-repl" id="subtitle"]]
[[!template text="""My init file has lots of classes,""" start="00:19:33.000" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and lots of global functions and lots of cruft,""" start="00:19:35.521" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so people hate that, of course.""" start="00:19:39.188" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is an example.""" start="00:19:43.700" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is the index at the top of my init file.""" start="00:19:46.341" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The classes start here. Then we have some functions""" start="00:19:52.416" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and then we have functions that load certain packages,""" start="00:19:57.542" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and then we have cruft, whatever.""" start="00:20:02.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Most people think that my style of using Lua""" start="00:20:06.580" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is dirty and dangerous,""" start="00:20:08.924" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and they wouldn't touch my Lua code with a 10 feet pole,""" start="00:20:10.123" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but most of the things""" start="00:20:14.288" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that I'm going to present here in this presentation""" start="00:20:15.969" video="mainVideo-repl" id="subtitle"]]
[[!template text="""are ideas that should be easy to port to other environments""" start="00:20:19.257" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and other languages, especially the diagrams,""" start="00:20:23.051" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so the code is not so important.""" start="00:20:27.739" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""LaTeX and LuaLaTeX""" start="00:20:31.000" video="mainVideo-repl" id="subtitle"]]

[[!template text="""Now let me talk a bit about LaTeX, LuaLaTeX,""" start="00:20:31.000" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is LaTeX with the Lua interpreter embedded inside""" start="00:20:34.641" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and two ways of generating pictures in LaTeX:""" start="00:20:39.250" video="mainVideo-repl" id="subtitle"]]
[[!template text="""TikZ that is very famous,""" start="00:20:43.183" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and Pict2e that is not very famous""" start="00:20:45.116" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and that is very low level,""" start="00:20:48.312" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I think that not many people use.""" start="00:20:50.645" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I said before that when I learned Lua,""" start="00:20:53.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I realized that it was very good""" start="00:20:57.049" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for writing literal languages.""" start="00:21:00.355" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I was doing my PhD at the time""" start="00:21:03.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and typesetting the diagrams for my PhD thesis""" start="00:21:05.987" video="mainVideo-repl" id="subtitle"]]
[[!template text="""was very boring.""" start="00:21:09.970" video="mainVideo-repl" id="subtitle"]]
[[!template text="""One of the things that I did was that""" start="00:21:11.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I created a literal language""" start="00:21:13.865" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for typesetting the diagrams for me.""" start="00:21:15.721" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It was called Dednat because initially""" start="00:21:19.340" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it only generated diagrams for natural deduction""" start="00:21:22.822" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and then it had several versions.""" start="00:21:26.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""These are the slides from my presentation about Dednat6""" start="00:21:30.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and Dednat6 is an extensible semi preprocessor""" start="00:21:34.380" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for LuaLaTeX that understands diagrams in ASCII art""" start="00:21:38.991" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the sense that when I have a TeX file that has this,""" start="00:21:43.692" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and when Dednat6 is loaded,""" start="00:21:49.035" video="mainVideo-repl" id="subtitle"]]
[[!template text="""when I get the right comments,""" start="00:21:52.144" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Dednat6 interprets this block here""" start="00:21:55.709" video="mainVideo-repl" id="subtitle"]]
[[!template text="""as something that defines this diagram.""" start="00:22:00.343" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It interprets this diagram here,""" start="00:22:05.096" video="mainVideo-repl" id="subtitle"]]
[[!template text="""this diagram in the comments here,""" start="00:22:07.829" video="mainVideo-repl" id="subtitle"]]
[[!template text="""as something that defines a diagram called `foo`,""" start="00:22:10.644" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a deduction called `foo`, and it generates this code here""" start="00:22:16.433" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so that we can just invoke the definition of the deduction""" start="00:22:23.065" video="mainVideo-repl" id="subtitle"]]
[[!template text="""by typing `\ded{foo}`.""" start="00:22:28.868" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Dednat6 also supports another language""" start="00:22:31.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for typesetting bidimensional diagrams with arrows and stuff""" start="00:22:36.149" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for category theory and blah blah.""" start="00:22:40.580" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The specifications of these diagrams""" start="00:22:43.123" video="mainVideo-repl" id="subtitle"]]
[[!template text="""look like this. Here is a very good example.""" start="00:22:46.100" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is a huge diagram. Sorry, one second.""" start="00:22:53.866" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So the source code that generates this diagram here""" start="00:23:00.940" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is just this thing at the left. It's very visual.""" start="00:23:04.758" video="mainVideo-repl" id="subtitle"]]
[[!template text="""We can typeset the diagram in ASCII art here.""" start="00:23:08.629" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Then in this part here,""" start="00:23:11.843" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we tell how the nodes are to be joined,""" start="00:23:14.435" video="mainVideo-repl" id="subtitle"]]
[[!template text="""which arrows have to have annotations, and so on.""" start="00:23:18.274" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This language is extensible in the sense that""" start="00:23:22.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""here, comments that start""" start="00:23:30.951" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with `%:` are interpreted as definitions""" start="00:23:37.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for tree diagrams,""" start="00:23:42.691" video="mainVideo-repl" id="subtitle"]]
[[!template text="""lines that start with `%D`""" start="00:23:44.820" video="mainVideo-repl" id="subtitle"]]
[[!template text="""define 2D diagrams with arrows and stuff,""" start="00:23:49.395" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and lines that start with command `%L`""" start="00:23:53.762" video="mainVideo-repl" id="subtitle"]]
[[!template text="""contain blocks of Lua code that we can use""" start="00:23:57.684" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to extend the interpreter on the flag.""" start="00:24:01.198" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, here are some recent examples""" start="00:24:05.528" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of diagrams that I used Dednat6 to typeset.""" start="00:24:09.747" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This diagram here was generated by this specification here,""" start="00:24:16.147" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and this diagram here with the curved arrows""" start="00:24:24.495" video="mainVideo-repl" id="subtitle"]]
[[!template text="""was generated by this specification here.""" start="00:24:30.620" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Dednat6 was very easy to extend.""" start="00:24:36.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""At some point I started to use it to generate diagrams""" start="00:24:39.175" video="mainVideo-repl" id="subtitle"]]
[[!template text="""using Pict2e, mainly for the classes""" start="00:24:43.044" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that I give at the university,""" start="00:24:46.068" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I teach mathematics in a place.""" start="00:24:49.674" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me show an animation. Here is a diagram""" start="00:24:53.862" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that I generated with Dednat6.""" start="00:24:58.980" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It is a flipbook animation,""" start="00:25:02.326" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we type page up and page down,""" start="00:25:05.386" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and we go to the next page of the book""" start="00:25:08.254" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and to the previous page of the book.""" start="00:25:10.784" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here is the source code that generates that.""" start="00:25:13.249" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This source code is not very visual,""" start="00:25:16.925" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so it's quite clumsy to edit""" start="00:25:19.701" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a diagram directly in the TeX file like that.""" start="00:25:21.800" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Manim""" start="00:25:28.280" video="mainVideo-repl" id="subtitle"]]

[[!template text="""These diagrams were inspired by something called Manim.""" start="00:25:28.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I've forgotten the name of the guy, but it's a guy""" start="00:25:33.438" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that makes many videos about mathematics,""" start="00:25:36.714" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and he created this library called Manim""" start="00:25:39.347" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for generating his animations.""" start="00:25:43.374" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Other people adapted his library to make it more accessible.""" start="00:25:46.418" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I tried to learn it, but each animation,""" start="00:25:52.084" video="mainVideo-repl" id="subtitle"]]
[[!template text="""even an animation with very few frames,""" start="00:25:55.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""each animation took ages to render, so it wasn't fun.""" start="00:25:59.192" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Animations and PDFs can be rendered in seconds,""" start="00:26:03.771" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so these things were fun for me""" start="00:26:08.346" video="mainVideo-repl" id="subtitle"]]
[[!template text="""because my laptop is very slow and Manim was not fun.""" start="00:26:11.161" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, writing code like this inside a TeX file""" start="00:26:17.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""was not very fun because it was hard to debug.""" start="00:26:24.264" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Generating diagrams from REPLs""" start="00:26:30.880" video="mainVideo-repl" id="subtitle"]]

[[!template text="""In 2022, I started to play with ways""" start="00:26:30.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of generating these diagrams from REPLs""" start="00:26:36.511" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I found a way for Pict2e and a way for Tikz.""" start="00:26:42.000" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Each one of these ways became a video.""" start="00:26:46.310" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If you go to the list of first class videos of eev,""" start="00:26:49.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""you're going to see""" start="00:26:53.221" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that there's a video about Pict2e here""" start="00:26:55.089" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and a video about Tikz.""" start="00:26:59.011" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here you have some information""" start="00:27:01.159" video="mainVideo-repl" id="subtitle"]]
[[!template text="""like length and explanation, etc.""" start="00:27:04.188" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here are the pages for these videos.""" start="00:27:07.509" video="mainVideo-repl" id="subtitle"]]
[[!template text="""My page about the video about Pict2e is like this.""" start="00:27:11.514" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It has some diagrams. This one is much nicer.""" start="00:27:15.992" video="mainVideo-repl" id="subtitle"]]
[[!template text="""A lot of people watched that video. I mean,""" start="00:27:20.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I thought that 250 people watched it.""" start="00:27:26.606" video="mainVideo-repl" id="subtitle"]]
[[!template text="""For me, that's a million of people.""" start="00:27:31.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This video is about how to extract diagrams""" start="00:27:35.345" video="mainVideo-repl" id="subtitle"]]
[[!template text="""from the Tikz manual, and how to run those examples in REPL""" start="00:27:40.403" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and modify them bit by bit. This is a screenshot.""" start="00:27:46.513" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me go back. At that point,""" start="00:27:52.937" video="mainVideo-repl" id="subtitle"]]
[[!template text="""these things were just prototypes,""" start="00:27:57.433" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the code was not very nice,""" start="00:28:01.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and in this year I wrote...""" start="00:28:04.804" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I was able to unify those two ways of generating PDFs,""" start="00:28:07.593" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the one for Tikz and the one for Pict2e.""" start="00:28:12.124" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I unified them with many other things""" start="00:28:15.666" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that generated diagrams.""" start="00:28:19.197" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The basis of these things is something called Show2.lua.""" start="00:28:21.299" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I'm not going to just show its details now,""" start="00:28:28.431" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but it's an extension that generates Tikz code.""" start="00:28:33.936" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It's just this. We can specify a diagram""" start="00:28:38.776" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with just a block like this, and then if we run `show00`,""" start="00:28:43.306" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it returns a string""" start="00:28:50.539" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is just the inner body of the TeX file.""" start="00:28:53.695" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If we run this, we see the whole TeX file.""" start="00:28:59.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If we run this we save the TeX file and""" start="00:29:02.307" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we compile the TeX file to generate a PDF.""" start="00:29:05.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If we run this, we show the PDF""" start="00:29:09.197" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the lower right window.""" start="00:29:12.558" video="mainVideo-repl" id="subtitle"]]
[[!template text="""That's the same thing for all my recent programs""" start="00:29:15.079" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that generate PDFs. They are all integrated.""" start="00:29:20.027" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here is the basis for all my modules""" start="00:29:23.811" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that generate diagrams with Pict2e.""" start="00:29:28.268" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Its demos are not very interesting.""" start="00:29:31.424" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me show some demos of extensions""" start="00:29:34.338" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that do interesting things. This is a diagram""" start="00:29:38.557" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that I created by editing it in a REPL,""" start="00:29:43.724" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I create several Pict objects here.""" start="00:29:47.902" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If I execute this, it compiles the object and""" start="00:29:51.872" video="mainVideo-repl" id="subtitle"]]
[[!template text="""generates a PDF. If I tap this, here is the PDF.""" start="00:29:57.819" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If I just ask Lua to display what is pux here,""" start="00:30:04.524" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it shows the source code in Pict2e of the diagram.""" start="00:30:10.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The nice thing is that it is indented,""" start="00:30:17.436" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so it's easy to debug the Pict2e code.""" start="00:30:20.933" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If anyone is interested, the module that does the tricks""" start="00:30:24.349" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for indentation is very easy to understand.""" start="00:30:28.505" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it has lots of tests and test blocks,""" start="00:30:31.948" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I think that its data structures are easy to understand.""" start="00:30:34.921" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, here is another example, the show is here.""" start="00:30:47.439" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It generates a 3D diagram.""" start="00:30:57.905" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Parsers""" start="00:31:03.240" video="mainVideo-repl" id="subtitle"]]

[[!template text="""Now let me talk about parsers""" start="00:31:03.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and REPLs in a very strange place.""" start="00:31:05.898" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I mean, using REPLs to build parsers step by step""" start="00:31:08.998" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and replacing parts by more complex parts.""" start="00:31:15.149" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I said that Lua is very minimalistic,""" start="00:31:20.439" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and everybody knows that""" start="00:31:24.493" video="mainVideo-repl" id="subtitle"]]
[[!template text="""implementations of regular expressions""" start="00:31:26.965" video="mainVideo-repl" id="subtitle"]]
[[!template text="""are big and complex. So instead of coming""" start="00:31:30.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with full regular expressions,""" start="00:31:33.974" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Lua comes with something called patterns""" start="00:31:36.376" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and a library function called string.match.""" start="00:31:41.321" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here is a copy of the part of the manual""" start="00:31:46.628" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that explains a part of the syntax of patterns.""" start="00:31:50.821" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here's how string.match is described in the manual.""" start="00:31:55.729" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It's just this: looks for the first match of pattern""" start="00:32:00.091" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the string s, blah blah blah.""" start="00:32:04.537" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Then we have to go to the other section of the manual""" start="00:32:06.546" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that explains patterns. Lua patterns are so simple,""" start="00:32:10.077" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so limited, that they don't even have""" start="00:32:18.198" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the alternation operator.""" start="00:32:23.222" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here is how it is described in the elisp manual,""" start="00:32:26.659" video="mainVideo-repl" id="subtitle"]]
[[!template text="""`\|` specifies an alternative, blah blah blah.""" start="00:32:33.136" video="mainVideo-repl" id="subtitle"]]
[[!template text="""When we want to build more complex regular expressions,""" start="00:32:39.678" video="mainVideo-repl" id="subtitle"]]
[[!template text="""patterns, grammars, etc.,""" start="00:32:45.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we have to use an external library for that.""" start="00:32:48.366" video="mainVideo-repl" id="subtitle"]]
[[!template text="""No, sorry, a library that is external,""" start="00:32:52.669" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but that was written by one of the authors of Lua itself.""" start="00:32:56.208" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This library is called Lpeg.""" start="00:33:01.472" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Its manual says Lpeg is""" start="00:33:03.944" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a new pattern matching library for Lua""" start="00:33:06.331" video="mainVideo-repl" id="subtitle"]]
[[!template text="""based on parsing expression grammars (PEGs).""" start="00:33:09.654" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The manual is very terse.""" start="00:33:14.773" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I found it incredibly hard to read.""" start="00:33:17.781" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it doesn't have any diagrams.""" start="00:33:21.946" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It has some examples, though.""" start="00:33:25.416" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The Lua wiki has a big page called Lpeg Tutorial""" start="00:33:28.770" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with lots of examples, but it also doesn't have diagrams.""" start="00:33:34.017" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I found some things incredibly hard to understand.""" start="00:33:39.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""For example, this is something""" start="00:33:43.132" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that is in the manual of Lpeg that I saw,""" start="00:33:45.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I thought, wow, great, this makes all sense""" start="00:33:48.062" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and this is going to be very useful.""" start="00:33:51.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It's a way to build grammars that can be recursive""" start="00:33:53.947" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and they sort of can encode BNF grammars,""" start="00:33:57.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""we just have to translate the BNF a bit""" start="00:34:01.301" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to get rid of some recursions""" start="00:34:05.129" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and to translate them to something else.""" start="00:34:07.593" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The manual also has some things that I thought,""" start="00:34:10.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""oh no, I don't have any idea of what this thing does.""" start="00:34:14.338" video="mainVideo-repl" id="subtitle"]]
[[!template text="""In fact, I saw these things for the first time""" start="00:34:17.846" video="mainVideo-repl" id="subtitle"]]
[[!template text="""more than 10 years ago, and they only started to make sense""" start="00:34:20.769" video="mainVideo-repl" id="subtitle"]]
[[!template text="""one year ago. One example is group captures.""" start="00:34:27.295" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Lpeg also comes with a module called the re module.""" start="00:34:32.273" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me pronounce it in Portuguese, the re module.""" start="00:34:37.835" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Its manual says the re module""" start="00:34:43.183" video="mainVideo-repl" id="subtitle"]]
[[!template text="""provided by the file re.lua in the distribution""" start="00:34:45.742" video="mainVideo-repl" id="subtitle"]]
[[!template text="""supports some odd conventional regular expression syntax""" start="00:34:49.504" video="mainVideo-repl" id="subtitle"]]
[[!template text="""for pattern usage within lpeg. This is a quick reference.""" start="00:34:56.758" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This thing is very brief. It has some nice examples,""" start="00:35:04.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but it's hard to understand anyway.""" start="00:35:08.465" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Here are some comments about""" start="00:35:11.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""my attempts to learn re.lua. This is a class.""" start="00:35:14.181" video="mainVideo-repl" id="subtitle"]]
[[!template text="""In this case, it's a very small class.""" start="00:35:18.632" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This file implements a `pm` method.""" start="00:35:22.362" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I'm going to show examples of other `pm` methods very soon.""" start="00:35:26.092" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So this is a `pm` method for re.lua""" start="00:35:31.401" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that lets us compare the syntax of lua patterns, lpeg,""" start="00:35:34.697" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and re. See this example here. If we run this,""" start="00:35:40.302" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it loads my version of lpeg, no sorry,""" start="00:35:46.632" video="mainVideo-repl" id="subtitle"]]
[[!template text="""my version of lpegrex. It shows that""" start="00:35:51.380" video="mainVideo-repl" id="subtitle"]]
[[!template text="""when we apply the `pm` method to this Lua pattern,""" start="00:35:56.014" video="mainVideo-repl" id="subtitle"]]
[[!template text="""this lpeg pattern, and this re pattern,""" start="00:36:01.553" video="mainVideo-repl" id="subtitle"]]
[[!template text="""they all give the same results.""" start="00:36:05.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So we can use this kind of thing here to show""" start="00:36:08.239" video="mainVideo-repl" id="subtitle"]]
[[!template text="""how to translate from Lua patterns that are familiar""" start="00:36:11.513" video="mainVideo-repl" id="subtitle"]]
[[!template text="""because they are similar to regular expressions,""" start="00:36:15.589" video="mainVideo-repl" id="subtitle"]]
[[!template text="""only weaker, to lpeg that is super weird,""" start="00:36:19.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and to re that is not so weird.""" start="00:36:25.252" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Anyway, the comment says that in 2012, I had a project""" start="00:36:30.085" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that needed a precedence parser""" start="00:36:35.426" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that could parse arithmetical expressions""" start="00:36:38.591" video="mainVideo-repl" id="subtitle"]]
[[!template text="""with the right precedences. At that point""" start="00:36:42.278" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I was still struggling with pure lpeg""" start="00:36:46.315" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I couldn't do much with it,""" start="00:36:49.032" video="mainVideo-repl" id="subtitle"]]
[[!template text="""so I tried to learn re.lua instead,""" start="00:36:51.319" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I wrote this old class here that allowed me to use""" start="00:36:54.577" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a preprocessor on patterns for Lua.""" start="00:36:59.292" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The thing is that with this preprocessor""" start="00:37:01.756" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I could specify precedence grammars using this thing here""" start="00:37:04.835" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that worked but was super clumsy,""" start="00:37:10.921" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I gave up after a few attempts.""" start="00:37:14.489" video="mainVideo-repl" id="subtitle"]]
[[!template text="""And in 2022 I heard about something called lpegrex""" start="00:37:18.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that was a kind of extension of re,""" start="00:37:25.633" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and it was much more powerful than re.lua,""" start="00:37:30.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but after a while I realized that""" start="00:37:33.046" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it had the same defects as re.lua.""" start="00:37:35.785" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me explain that,""" start="00:37:38.766" video="mainVideo-repl" id="subtitle"]]
[[!template text="""because it has all to do with the things""" start="00:37:40.699" video="mainVideo-repl" id="subtitle"]]
[[!template text="""about black boxes and magic that I told in the beginning.""" start="00:37:43.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Neither re.lua or lpegrex had some features that I needed.""" start="00:37:52.027" video="mainVideo-repl" id="subtitle"]]
[[!template text="""They received a pattern that was specified as a string""" start="00:37:59.047" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and it converted that into an lpeg pattern,""" start="00:38:05.375" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but it didn't let us explore the lpeg patterns""" start="00:38:08.869" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that it generated.""" start="00:38:12.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Their code was written in a way that was REPL-unfriendly.""" start="00:38:14.530" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I couldn't modify parts of the code bit by bit in a REPL""" start="00:38:20.663" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and try to change the code""" start="00:38:26.282" video="mainVideo-repl" id="subtitle"]]
[[!template text="""without changing the original file, say.""" start="00:38:28.944" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The code was very hard to explore, to hack,""" start="00:38:32.036" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and to extend in my opinion.""" start="00:38:35.354" video="mainVideo-repl" id="subtitle"]]
[[!template text="""The documentation was not very clear,""" start="00:38:38.239" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I sent wonderful messages to the""" start="00:38:42.019" video="mainVideo-repl" id="subtitle"]]
[[!template text="""developer of lpegrex, and he was too busy to help me.""" start="00:38:45.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""He answered very briefly. To be honest, I felt rejected.""" start="00:38:51.014" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I felt that I wasn't doing anything interesting, whatever.""" start="00:38:57.211" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""ELpeg1.lua""" start="00:39:03.200" video="mainVideo-repl" id="subtitle"]]

[[!template text="""So in 2022, I was trying to learn lpegrex""" start="00:39:03.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""because I was thinking that it would solve my problems,""" start="00:39:07.471" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but it didn't. It didn't have the features that I needed,""" start="00:39:13.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and it was hard to extend and""" start="00:39:16.667" video="mainVideo-repl" id="subtitle"]]
[[!template text="""how to explore and hard to debug.""" start="00:39:18.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I decided to rewrite it in a more hacker-friendly way,""" start="00:39:22.303" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in the sense that it was modular""" start="00:39:28.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and I could replace any part of the module from a REPL.""" start="00:39:32.036" video="mainVideo-repl" id="subtitle"]]
[[!template text="""My version of it was called ELpeg1.lua.""" start="00:39:37.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I decided that in my version I wouldn't""" start="00:39:42.641" video="mainVideo-repl" id="subtitle"]]
[[!template text="""have the part that receives a grammar""" start="00:39:48.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""specified as a string and converts that to lpeg.""" start="00:39:51.241" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I would just have the backend part""" start="00:39:55.266" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that are the functions in lpeg""" start="00:39:58.985" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that let us specify powerful grammars.""" start="00:40:02.172" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Let me go back. Let me explain a bit about lpeg.""" start="00:40:06.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Lua has coercions. The `+` expects to receive two numbers.""" start="00:40:15.162" video="mainVideo-repl" id="subtitle"]]
[[!template text="""If one of its arguments or both of them are strings,""" start="00:40:20.781" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it converts the strings to numbers.""" start="00:40:25.931" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So in this case here, `2 + &quot;3&quot;` returns the number 5.""" start="00:40:30.117" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is the concatenation operator.""" start="00:40:37.092" video="mainVideo-repl" id="subtitle"]]
[[!template text="""It expects to receive strings. In this case, it will""" start="00:40:40.441" video="mainVideo-repl" id="subtitle"]]
[[!template text="""convert the number 2 to the string &quot;2&quot;""" start="00:40:44.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and the concatenation of these two things will be""" start="00:40:47.542" video="mainVideo-repl" id="subtitle"]]
[[!template text="""&quot;23&quot;. Oops, sorry, &quot;23&quot; as a string.""" start="00:40:50.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""lpeg also has some coercions. I usually set these globals""" start="00:40:55.918" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to let me write my grammars in a very compact way.""" start="00:41:04.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So instead of lpeg.B, lpeg.C, etc.""" start="00:41:10.014" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I use globals like B, C, and so on.""" start="00:41:13.812" video="mainVideo-repl" id="subtitle"]]
[[!template text="""And with these globals I can write""" start="00:41:17.879" video="mainVideo-repl" id="subtitle"]]
[[!template text="""things like this, `C(1) * &quot;_&quot;`. And lpeg knows that lpeg.C,""" start="00:41:21.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""sorry, it sort of expands these to lpeg.C,""" start="00:41:36.048" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but lpeg.C expects to receive an lpeg pattern""" start="00:41:41.148" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and 1 is not yet an lpeg pattern.""" start="00:41:43.591" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So it is coerced into an lpeg pattern by calling lpeg.P.""" start="00:41:48.548" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So this short thing here becomes equivalent to""" start="00:41:53.348" video="mainVideo-repl" id="subtitle"]]
[[!template text="""`lpeg.C(lpeg.P(1))`. And the multiplication when at least one of""" start="00:42:02.482" video="mainVideo-repl" id="subtitle"]]
[[!template text="""its arguments is an lpeg pattern, it expects to receive two lpeg patterns. And in this""" start="00:42:07.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""case the one at the right is just a string, so it is coerced to an lpeg pattern by using""" start="00:42:13.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""lpeg.P. With this idea we can sort of understand this comparison here. I mean, let me run it""" start="00:42:19.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""again. This first part is very similar to a regular expression here at the left. And""" start="00:42:29.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""when we apply this lpeg, sorry, this lua pattern to this subject here, the result is this thing""" start="00:42:37.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""here, this thing, this thing and this thing. I'm going to call each one of these results""" start="00:42:51.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""captures. So each of these things between parentheses captures a substring of the original""" start="00:42:56.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""string and these captured substrings are returned in a certain order. Here is how to express""" start="00:43:04.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the same thing in lpeg. It's very cryptic, but it's a good way to understand some basic""" start="00:43:11.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""operators of lpeg. I mean, we can look at the menu and understand what C, S and R do""" start="00:43:20.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and also exponentiation. And this strange thing here receives this string here, runs""" start="00:43:29.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a function that I have defined that converts it to an object of a certain class and that""" start="00:43:41.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""class represents re patterns. So this thing is treated as a pattern for re.lua and it""" start="00:43:46.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is matched again the string and it returns the same thing as the other one. Also this""" start="00:43:55.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""thing here also has a comparison with lpeg.rex, but these patterns are very, very trivial.""" start="00:44:04.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""They don't do anything very strange. So let's go back and see what kinds of very strange""" start="00:44:10.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""things there are. Here is the page of lpeg.rex at GitHub. Here is the documentation. It's""" start="00:44:17.340" video="mainVideo-repl" id="subtitle"]]
[[!template text="""relatively brief. It explains lpeg.rex as being an extension of re.lua. So""" start="00:44:31.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it explains mainly the additional features. Here is a quick reference that explains only""" start="00:44:39.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the additional features. Some of these things I was able to understand by struggling a lot,""" start="00:44:44.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and some I wasn't able to even by spending several evenings trying to build examples.""" start="00:44:56.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This is something very nice. lpeg.rex comes with some example parsers. Here is""" start="00:45:08.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a parser that parses the lua grammar. I mean, this is the grammar for lua 5.4 at the end""" start="00:45:16.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of the reference manual. It's just this. And this is a kind of BNF, and this is the BNF""" start="00:45:25.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""translated to the language of lpeg.rex. This thing uses many constructions that are""" start="00:45:35.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in re.lua and some extra constructions that are described here. With these examples,""" start="00:45:43.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I was able to understand some of these things here that are described here in the quick""" start="00:45:51.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""reference, but not all. So I wasn't able to use lpeg.rex by itself because some things""" start="00:46:00.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""didn't make much sense. I decided to re implement it in my own style because that""" start="00:46:13.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""would be a way to map... at the very least, map what I understood and what I didn't and""" start="00:46:21.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""learn one feature at a time, do comparisons and so on. Here I pointed to two features""" start="00:46:29.120" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of lpeg. One I said, oh great, this thing can be used to define grammars, even recursive""" start="00:46:38.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""grammars and so on. And this is an &quot;oh no&quot; feature. One thing that didn't make any sense at all:""" start="00:46:44.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""group captures. One thing that I did to understand group captures was to represent them as diagrams.""" start="00:46:52.260" video="mainVideo-repl" id="subtitle"]]
[[!template text="""Of course in the beginning I was drawing these diagrams by hand, but then I realized that""" start="00:47:01.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I could use the bits of lpeg that I already knew to build a grammar that would parse a""" start="00:47:08.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""little language and generate these diagrams in LaTeX. I was able to make this. In""" start="00:47:16.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""this diagram here, this thing above the arrow is a piece of Lua code that specifies an lpeg""" start="00:47:24.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""pattern. This thing here at the top is the string that is being matched and the things""" start="00:47:35.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""below the under braces are the captures that each thing captures. For example, this under""" start="00:47:43.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""brace here corresponds to this pattern here that parses a single character but doesn't""" start="00:47:57.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""return any captures. This thing here parses a single B and doesn't return any captures.""" start="00:48:03.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""This thing here parses a single character and captures it. And this thing here parses""" start="00:48:10.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the character D and captures it. And this other thing here that transforms this pattern""" start="00:48:17.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""into another pattern returns first a capture with all the string that was parsed by this""" start="00:48:24.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""pattern here and then all the captures returned by this thing here before the column. So this""" start="00:48:35.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""was a way to build concrete examples for things that the lpeg manual was explaining in a very""" start="00:48:44.000" video="mainVideo-repl" id="subtitle"]]
[[!template text="""terse way and it worked for me. Some things that were very mysterious started to make""" start="00:48:51.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""sense and I started to have intelligent questions to ask in the mailing list. With that""" start="00:48:58.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I was able to understand what are group captures that receive a name. Well, let me explain""" start="00:49:10.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""what this does. This thing here parses the empty string and returns this as a constant.""" start="00:49:22.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""So this is something that doesn't exist in regular expressions. It parses nothing and""" start="00:49:30.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""returns this as a capture. Then this thing here returns two constants here and parses""" start="00:49:38.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the empty string. And this thing here, D, converts the results of this thing here into""" start="00:49:46.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a group capture and stores it in the label D. And then here's another constant capture.""" start="00:49:54.440" video="mainVideo-repl" id="subtitle"]]

[[!template new="1" text="""Building lists""" start="00:50:04.160" video="mainVideo-repl" id="subtitle"]]

[[!template text="""I realized that these things here were similar to how Lua specifies building lists.""" start="00:50:04.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""When we build a table and we say that the first element of the table is here, this element""" start="00:50:15.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is put at the end of the table. After that we say D equals to say 42. We are putting""" start="00:50:22.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the 42 in the slot whose key is D. This was happening with lpeg captures but there was""" start="00:50:30.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""something very strange. These group captures could hold more than one capture, more than""" start="00:50:39.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""one value. So there was something between lists and tables. I started to use this notation""" start="00:50:49.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to explain in my notation what they were doing. Many things started to make sense, many mysterious""" start="00:50:57.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""sentences in the manual started to make sense but some didn't. But at least I was able to""" start="00:51:09.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""send some intelligent questions to the mailing list and the author of Lua and LPEG answered""" start="00:51:20.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""some of them. He was not very happy about my questions. He told me that those diagrams""" start="00:51:26.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""were a waste of time, the manual was perfectly clear and so on, whatever. So it was weird,""" start="00:51:35.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""but I was able to understand lots of things from his answers. So this is a copy of one""" start="00:51:47.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""of my messages, then there's another one, another one, some of the diagrams. Then he""" start="00:51:56.440" video="mainVideo-repl" id="subtitle"]]
[[!template text="""complained about these diagrams, he said that these things here that look like table constructions""" start="00:52:02.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""do not exist, whatever. Anyway, once I understood group captures, many features were very easy""" start="00:52:10.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to understand and I started to be able to use lpeg to build some very interesting things.""" start="00:52:22.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I was able to reproduce some of the features that I saw in lpegrex. Remember that this""" start="00:52:30.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""is a syntax of Lua. Here I was able to understand how these things here were translated to lpeg""" start="00:52:39.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""code, to lpeg patterns by using group captures in a certain way. I was able to implement""" start="00:52:53.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""them in ELpeg1.lua. after some time I was able to use ELpeg1.lua to build grammars that""" start="00:53:02.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""were able to parse arithmetical expressions with the right precedence. here's an example""" start="00:53:13.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""in which I built the grammar step by step and I test the current grammar and I replace""" start="00:53:21.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""a bit and then I test the new grammar and so on. You can see that the result is""" start="00:53:26.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""always a tree that is drawn in a nice two dimensional way. At this point, these powers""" start="00:53:34.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""here are returned as a list, as an operation power with several arguments here and then""" start="00:53:48.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I apply a kind of parsing combinator here that transforms these trees into other trees""" start="00:53:57.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and with these combinators here I can specify that the power is associative in a certain""" start="00:54:05.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""direction, the division is associative in another direction, the minus uses the same""" start="00:54:14.200" video="mainVideo-repl" id="subtitle"]]
[[!template text="""direction as a division and so on and they have the right precedences. So here are the""" start="00:54:22.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""tests. So here's my file ELpeg.lua, it has several classes. Each class has tests after""" start="00:54:29.520" video="mainVideo-repl" id="subtitle"]]
[[!template text="""it. I was able to implement something that lpeg.rex has that's called keywords, that's""" start="00:54:42.360" video="mainVideo-repl" id="subtitle"]]
[[!template text="""very useful for parsing problems in programming languages. I was able to implement something""" start="00:54:52.040" video="mainVideo-repl" id="subtitle"]]
[[!template text="""similar to the debugger, to the pack debugger that lpeg uses, but I was frustrated by some""" start="00:54:59.160" video="mainVideo-repl" id="subtitle"]]
[[!template text="""limitations of the debugger and I implemented my own that is much better and let me show""" start="00:55:10.640" video="mainVideo-repl" id="subtitle"]]
[[!template text="""something else. I was able to translate a good part of the Lua parser here to lpeg1.lua.""" start="00:55:23.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""I haven't finished yet but I have most of the translation here and after having all""" start="00:55:33.800" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that I was able to build other grammars very quickly. Writing new parsers finally became""" start="00:55:45.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""fun and here's one example that I showed in the beginning. If I remember correctly, I""" start="00:55:54.960" video="mainVideo-repl" id="subtitle"]]
[[!template text="""took a figure from the Wikipedia, I don't have its link now, but I specify a grammar""" start="00:56:08.560" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that parses exactly the example that appears in the Wikipedia. So with my grammar, considering""" start="00:56:15.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""that the top level entry is statement, when I parse this string here, the result is this""" start="00:56:24.280" video="mainVideo-repl" id="subtitle"]]
[[!template text="""tree and I can do some operations on that. I can define how this thing is to be converted""" start="00:56:36.680" video="mainVideo-repl" id="subtitle"]]
[[!template text="""into LaTeX. I can define other operations that convert trees into other trees and here's""" start="00:56:44.840" video="mainVideo-repl" id="subtitle"]]
[[!template text="""some tests of these operations. This is what I showed in the beginning. I'm not going to""" start="00:56:53.400" video="mainVideo-repl" id="subtitle"]]
[[!template text="""explain all the details of this thing now. This show converts this thing into LaTeX in""" start="00:57:01.760" video="mainVideo-repl" id="subtitle"]]
[[!template text="""the way specified by these instructions here. And here's the result, the LaTeX result.""" start="00:57:10.480" video="mainVideo-repl" id="subtitle"]]
[[!template text="""These diagrams here are generated by this file here that defines a simple grammar that""" start="00:57:39.320" video="mainVideo-repl" id="subtitle"]]
[[!template text="""parses this thing here and then LaTeX it in a certain way and also tests to check if this""" start="00:57:46.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""code here that is Lua code that generates an lpeg grammar, parses this subject here, and""" start="00:57:56.720" video="mainVideo-repl" id="subtitle"]]
[[!template text="""returns the expected result. So this is the code that I wanted to show. I wanted to show""" start="00:58:06.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""many more things, but I wasn't able to prepare them before the conference. And I hope that""" start="00:58:16.880" video="mainVideo-repl" id="subtitle"]]
[[!template text="""soon, for some value of soon, I'll be able to create REPL based tutorials for LPG, G and""" start="00:58:23.920" video="mainVideo-repl" id="subtitle"]]
[[!template text="""ELpeg1.Lua where Lpeg is something very famous. Here is a module of LPG. I could also do something""" start="00:58:33.240" video="mainVideo-repl" id="subtitle"]]
[[!template text="""like this for ELpeg, and ELpeg1.lua is the thing that I wrote, the one that has tests in comments""" start="00:58:42.080" video="mainVideo-repl" id="subtitle"]]
[[!template text="""and the tests usually generate trees and sometimes they generate tag code. So that's it, I wanted""" start="00:58:55.600" video="mainVideo-repl" id="subtitle"]]
[[!template text="""to present much more, but I wasn't able to prepare it. So sorry, thanks, bye!""" start="00:59:04.920" video="mainVideo-repl" id="subtitle"]]

Questions or comments? Please e-mail [eduardoochs@gmail.com](mailto:eduardoochs@gmail.com?subject=Comment%20for%20EmacsConf%202023%20repl%3A%20REPLs%20in%20strange%20places%3A%20Lua%2C%20LaTeX%2C%20LPeg%2C%20LPegRex%2C%20TikZ)


<!-- End of emacsconf-publish-after-page -->