forked from DeathKing/Learning-SICP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlec10b.eng.ass
1337 lines (1334 loc) · 102 KB
/
lec10b.eng.ass
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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
YCbCr Matrix: TV.601
PlayResX: 640
PlayResY: 480
[Aegisub Project Garbage]
Active Line: 1311
Video Position: 103256
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: EN,Calisto MT,21,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
Style: Declare,微软雅黑,30,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,0,8,10,10,10,1
Style: staff,微软雅黑,30,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,0,2,5,10,10,10,1
Style: title,微软雅黑,35,&H001D64D9,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,0,1,5,10,10,10,1
Style: Default,雅黑宋体,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:11.88,0:00:18.11,EN,,0,0,0,,Storage Allocation & Garbage Collection
Dialogue: 0,0:00:18.91,0:00:20.61,EN,,0,0,0,,PROFESSOR: Well, there's one bit of mystery left,
Dialogue: 0,0:00:21.16,0:00:23.36,EN,,0,0,0,,which I'd like to get rid of right now.
Dialogue: 0,0:00:24.44,0:00:28.80,EN,,0,0,0,,And that's that we've been blithely doing things like cons
Dialogue: 0,0:00:30.00,0:00:31.62,EN,,0,0,0,,assuming there's always another one.
Dialogue: 0,0:00:32.80,0:00:36.32,EN,,0,0,0,,That we've been doing these things like
Dialogue: 0,0:00:36.51,0:00:37.44,EN,,0,0,0,,car-ing and cdr-ing
Dialogue: 0,0:00:37.47,0:00:38.72,EN,,0,0,0,,and assuming that we had some idea
Dialogue: 0,0:00:38.75,0:00:39.74,EN,,0,0,0,,how this can be done.
Dialogue: 0,0:00:40.02,0:00:40.67,EN,,0,0,0,,Now indeed
Dialogue: 0,0:00:41.07,0:00:44.40,EN,,0,0,0,,we said that that's equivalent to having procedures.
Dialogue: 0,0:00:45.37,0:00:47.57,EN,,0,0,0,,OK? But that doesn't really solve the problem,
Dialogue: 0,0:00:47.73,0:00:50.25,EN,,0,0,0,,because the procedure need all sorts of complicated mechanisms
Dialogue: 0,0:00:50.27,0:00:51.37,EN,,0,0,0,,like environment structures
Dialogue: 0,0:00:51.64,0:00:52.76,EN,,0,0,0,,and things like that to work.
Dialogue: 0,0:00:53.01,0:00:54.89,EN,,0,0,0,,And those were ultimately made out of conses
Dialogue: 0,0:00:54.89,0:00:56.42,EN,,0,0,0,,in the model that we had,
Dialogue: 0,0:00:56.70,0:00:58.47,EN,,0,0,0,,so that really doesn't solve the problem.
Dialogue: 0,0:00:59.38,0:01:01.13,EN,,0,0,0,,Now the problem here is
Dialogue: 0,0:01:01.31,0:01:03.97,EN,,0,0,0,,is the glue the data structure's made out of.
Dialogue: 0,0:01:04.76,0:01:06.40,EN,,0,0,0,,What kind of possible thing could it be?
Dialogue: 0,0:01:07.04,0:01:10.46,EN,,0,0,0,,OK? We've been showing you things like a machine,
Dialogue: 0,0:01:10.46,0:01:13.96,EN,,0,0,0,,a computer that has a controller,
Dialogue: 0,0:01:14.27,0:01:15.45,EN,,0,0,0,,and some registers,
Dialogue: 0,0:01:15.45,0:01:16.47,EN,,0,0,0,,and maybe a stack.
Dialogue: 0,0:01:16.98,0:01:18.12,EN,,0,0,0,,And we haven't said anything about,
Dialogue: 0,0:01:18.16,0:01:19.95,EN,,0,0,0,,for example, larger memory.
Dialogue: 0,0:01:20.57,0:01:22.38,EN,,0,0,0,,And I think that's what we have to worry about right now.
Dialogue: 0,0:01:23.74,0:01:26.56,EN,,0,0,0,,But just to make it perfectly clear
Dialogue: 0,0:01:26.59,0:01:27.88,EN,,0,0,0,,that this is an inessential,
Dialogue: 0,0:01:28.82,0:01:30.79,EN,,0,0,0,,purely implementational thing,
Dialogue: 0,0:01:31.10,0:01:32.60,EN,,0,0,0,,I'd like to show you, for example,
Dialogue: 0,0:01:32.60,0:01:34.20,EN,,0,0,0,,how you can do it all with the numbers.
Dialogue: 0,0:01:35.23,0:01:36.82,EN,,0,0,0,,That's an easy one.
Dialogue: 0,0:01:37.59,0:01:39.00,EN,,0,0,0,,Famous fellow by the name of Godel,
Dialogue: 0,0:01:44.09,0:01:46.01,EN,,0,0,0,,a logician at the end of the 1930s,
Dialogue: 0,0:01:46.38,0:01:48.70,EN,,0,0,0,,invented a very clever way
Dialogue: 0,0:01:48.70,0:01:52.27,EN,,0,0,0,,of encoding the complicated expressions
Dialogue: 0,0:01:52.81,0:01:53.52,EN,,0,0,0,,as numbers.
Dialogue: 0,0:01:54.32,0:01:55.05,EN,,0,0,0,,For example--
Dialogue: 0,0:01:55.05,0:01:58.00,EN,,0,0,0,,I'm not saying exactly what Godel's scheme is,
Dialogue: 0,0:01:58.00,0:01:59.48,EN,,0,0,0,,because he didn't use words like cons.
Dialogue: 0,0:01:59.66,0:02:00.60,EN,,0,0,0,,He had other kinds of
Dialogue: 0,0:02:00.91,0:02:02.60,EN,,0,0,0,,of ways of combining to make expressions.
Dialogue: 0,0:02:03.09,0:02:03.88,EN,,0,0,0,,But he said,
Dialogue: 0,0:02:03.92,0:02:06.81,EN,,0,0,0,,I'm going to assign a number to every algebraic expression.
Dialogue: 0,0:02:07.92,0:02:09.72,EN,,0,0,0,,And the way I'm going to manufacture these numbers
Dialogue: 0,0:02:09.72,0:02:11.65,EN,,0,0,0,,is by combining the numbers of the parts.
Dialogue: 0,0:02:12.47,0:02:13.45,EN,,0,0,0,,So for example,
Dialogue: 0,0:02:13.62,0:02:15.35,EN,,0,0,0,,what we were doing our world,
Dialogue: 0,0:02:15.35,0:02:18.01,EN,,0,0,0,,we could say that if objects
Dialogue: 0,0:02:20.78,0:02:22.22,EN,,0,0,0,,are represented by numbers,
Dialogue: 0,0:02:30.67,0:02:37.93,EN,,0,0,0,,then cons of x and y
Dialogue: 0,0:02:38.04,0:02:41.07,EN,,0,0,0,,could be represented by,
Dialogue: 0,0:02:41.55,0:02:43.77,EN,,0,0,0,,2 to the x times 3 to the y.
Dialogue: 0,0:02:46.13,0:02:48.03,EN,,0,0,0,,Because then we could extract the parts.
Dialogue: 0,0:02:49.56,0:02:50.97,EN,,0,0,0,,We could say, for example,
Dialogue: 0,0:02:51.18,0:02:55.88,EN,,0,0,0,,that then car of, say, x
Dialogue: 0,0:02:56.55,0:03:05.18,EN,,0,0,0,,is the number of factors of 2 in x.
Dialogue: 0,0:03:06.69,0:03:08.78,EN,,0,0,0,,OK? And of course cdr is the same thing.
Dialogue: 0,0:03:10.69,0:03:15.57,EN,,0,0,0,,It's the number of factors of 3 in x.
Dialogue: 0,0:03:16.51,0:03:18.65,EN,,0,0,0,,Now this is a perfectly reasonable scheme,
Dialogue: 0,0:03:19.10,0:03:20.11,EN,,0,0,0,,except for the fact that
Dialogue: 0,0:03:20.12,0:03:22.52,EN,,0,0,0,,the numbers rapidly get to be much larger
Dialogue: 0,0:03:22.83,0:03:23.98,EN,,0,0,0,,in number of digits
Dialogue: 0,0:03:24.32,0:03:26.55,EN,,0,0,0,,than the number of protons in the universe.
Dialogue: 0,0:03:27.95,0:03:29.88,EN,,0,0,0,,So there's no easy way to use this scheme
Dialogue: 0,0:03:29.90,0:03:31.21,EN,,0,0,0,,other than the theoretical one.
Dialogue: 0,0:03:33.43,0:03:34.48,EN,,0,0,0,,On the other hand,
Dialogue: 0,0:03:35.12,0:03:37.55,EN,,0,0,0,,there are other ways of representing these things.
Dialogue: 0,0:03:38.45,0:03:40.01,EN,,0,0,0,,We have been thinking in terms
Dialogue: 0,0:03:40.25,0:03:42.42,EN,,0,0,0,,of little boxes, boxes.
Dialogue: 0,0:03:43.32,0:03:46.43,EN,,0,0,0,,We've been thinking about our cons structures
Dialogue: 0,0:03:46.50,0:03:48.05,EN,,0,0,0,,as looking sort of like this.
Dialogue: 0,0:03:50.28,0:03:52.57,EN,,0,0,0,,They're little pigeon holes with things in them.
Dialogue: 0,0:03:53.56,0:03:55.47,EN,,0,0,0,,And of course we arrange them in little trees.
Dialogue: 0,0:03:57.21,0:03:59.97,EN,,0,0,0,,I wish that the semiconductor manufacturers
Dialogue: 0,0:03:59.97,0:04:02.07,EN,,0,0,0,,would supply me with something appropriate for this,
Dialogue: 0,0:04:02.70,0:04:03.76,EN,,0,0,0,,but actually
Dialogue: 0,0:04:03.85,0:04:05.31,EN,,0,0,0,,what they do supply me with
Dialogue: 0,0:04:06.20,0:04:07.96,EN,,0,0,0,,is a linear memory.
Dialogue: 0,0:04:09.38,0:04:13.46,EN,,0,0,0,,Memory is sort of a big pile of pigeonholes,
Dialogue: 0,0:04:15.12,0:04:16.34,EN,,0,0,0,,pigeonholes like this.
Dialogue: 0,0:04:17.72,0:04:20.25,EN,,0,0,0,,Each of which can hold a certain sized object,
Dialogue: 0,0:04:20.94,0:04:22.20,EN,,0,0,0,,a fixed size object.
Dialogue: 0,0:04:23.39,0:04:24.07,EN,,0,0,0,,So, for example,
Dialogue: 0,0:04:24.07,0:04:25.66,EN,,0,0,0,,a complicated list with 25 elements
Dialogue: 0,0:04:25.66,0:04:26.64,EN,,0,0,0,,won't fit in one of these.
Dialogue: 0,0:04:28.55,0:04:29.26,EN,,0,0,0,,However, each of these
Dialogue: 0,0:04:29.29,0:04:30.88,EN,,0,0,0,,is indexed by an address.
Dialogue: 0,0:04:33.97,0:04:34.99,EN,,0,0,0,,So the address might be
Dialogue: 0,0:04:35.02,0:04:35.50,EN,,0,0,0,,zero here,
Dialogue: 0,0:04:35.50,0:04:36.22,EN,,0,0,0,,one here,
Dialogue: 0,0:04:36.22,0:04:36.70,EN,,0,0,0,,two here,
Dialogue: 0,0:04:36.70,0:04:37.25,EN,,0,0,0,,three here,
Dialogue: 0,0:04:37.25,0:04:37.94,EN,,0,0,0,,and so on.
Dialogue: 0,0:04:38.06,0:04:40.40,EN,,0,0,0,,That we write these down as numbers is unimportant.
Dialogue: 0,0:04:40.40,0:04:41.68,EN,,0,0,0,,What matters is that they're distinct
Dialogue: 0,0:04:41.95,0:04:43.42,EN,,0,0,0,,as a way to get to the next one.
Dialogue: 0,0:04:44.97,0:04:46.14,EN,,0,0,0,,And inside of each of these,
Dialogue: 0,0:04:46.36,0:04:49.11,EN,,0,0,0,,we can stuff something into these pigeonholes.
Dialogue: 0,0:04:49.53,0:04:50.77,EN,,0,0,0,,That's what memory is like,
Dialogue: 0,0:04:51.02,0:04:53.66,EN,,0,0,0,,for those of you who haven't built a computer.
Dialogue: 0,0:04:54.15,0:04:54.65,EN,,0,0,0,,Now.
Dialogue: 0,0:04:56.69,0:04:57.53,EN,,0,0,0,,Now the problem is
Dialogue: 0,0:04:57.53,0:04:59.97,EN,,0,0,0,,how are we going to impose on this type of structure,
Dialogue: 0,0:05:00.42,0:05:01.72,EN,,0,0,0,,this nice tree structure.
Dialogue: 0,0:05:03.29,0:05:04.57,EN,,0,0,0,,Well it's not very hard,
Dialogue: 0,0:05:04.57,0:05:06.35,EN,,0,0,0,,and there have been numerous schemes involved in this.
Dialogue: 0,0:05:06.87,0:05:08.80,EN,,0,0,0,,The most important one is to say,
Dialogue: 0,0:05:08.80,0:05:11.18,EN,,0,0,0,,well assuming that the semiconductor manufacturer
Dialogue: 0,0:05:11.20,0:05:13.90,EN,,0,0,0,,allows me to arrange my memory
Dialogue: 0,0:05:13.98,0:05:15.77,EN,,0,0,0,,so that one of these pigeonholes is big enough
Dialogue: 0,0:05:16.28,0:05:18.20,EN,,0,0,0,,to hold the address of another
Dialogue: 0,0:05:19.35,0:05:20.83,EN,,0,0,0,,OK. I have been made.
Dialogue: 0,0:05:22.05,0:05:23.45,EN,,0,0,0,,Now it actually has to be a little bit bigger
Dialogue: 0,0:05:23.48,0:05:27.52,EN,,0,0,0,,because I have to also install or store some information
Dialogue: 0,0:05:27.56,0:05:30.09,EN,,0,0,0,,as to a tag which describes the kind of thing that's there.
Dialogue: 0,0:05:30.39,0:05:31.64,EN,,0,0,0,,And we'll see that in a second.
Dialogue: 0,0:05:32.62,0:05:34.40,EN,,0,0,0,,And of course if the semiconductor manufacturer
Dialogue: 0,0:05:34.43,0:05:35.88,EN,,0,0,0,,doesn't arrange it so I can do that,
Dialogue: 0,0:05:36.08,0:05:38.44,EN,,0,0,0,,then of course I can, with some cleverness,
Dialogue: 0,0:05:38.57,0:05:41.82,EN,,0,0,0,,arrange combinations of these to fit together in that way.
Dialogue: 0,0:05:43.77,0:05:47.05,EN,,0,0,0,,So we're going to have to imagine
Dialogue: 0,0:05:47.05,0:05:49.54,EN,,0,0,0,,imposing this complicated tree structure
Dialogue: 0,0:05:49.54,0:05:51.20,EN,,0,0,0,,on our nice linear memory.
Dialogue: 0,0:05:51.74,0:05:54.47,EN,,0,0,0,,If we look at the first still store,
Dialogue: 0,0:05:54.47,0:05:58.30,EN,,0,0,0,,we see a classic scheme for doing that.
Dialogue: 0,0:05:59.49,0:06:02.62,EN,,0,0,0,,It's a standard way of representing list structures
Dialogue: 0,0:06:03.22,0:06:05.87,EN,,0,0,0,,in a linear memory.
Dialogue: 0,0:06:06.27,0:06:08.32,EN,,0,0,0,,What we do is we divide this memory
Dialogue: 0,0:06:08.88,0:06:11.12,EN,,0,0,0,,into two parts.
Dialogue: 0,0:06:12.03,0:06:13.42,EN,,0,0,0,,An array called the cars,
Dialogue: 0,0:06:14.45,0:06:15.88,EN,,0,0,0,,and an array called the cdrs.
Dialogue: 0,0:06:17.58,0:06:18.86,EN,,0,0,0,,Now whether those happen to be
Dialogue: 0,0:06:18.88,0:06:21.04,EN,,0,0,0,,sequential addresses or whatever,
Dialogue: 0,0:06:21.12,0:06:22.00,EN,,0,0,0,,it's not important.
Dialogue: 0,0:06:22.87,0:06:25.20,EN,,0,0,0,,That's somebody's implementation details.
Dialogue: 0,0:06:25.80,0:06:28.40,EN,,0,0,0,,But there are two arrays here.
Dialogue: 0,0:06:28.96,0:06:30.36,EN,,0,0,0,,Linear arrays indexed
Dialogue: 0,0:06:30.46,0:06:32.59,EN,,0,0,0,,by sequential indices like this.
Dialogue: 0,0:06:34.84,0:06:36.85,EN,,0,0,0,,What is stored in each of these pigeonholes
Dialogue: 0,0:06:37.46,0:06:39.85,EN,,0,0,0,,is a typed object.
Dialogue: 0,0:06:41.43,0:06:42.57,EN,,0,0,0,,And what we have here
Dialogue: 0,0:06:42.57,0:06:45.71,EN,,0,0,0,,are types which begin with letters like p,
Dialogue: 0,0:06:45.71,0:06:46.57,EN,,0,0,0,,standing for a pair.
Dialogue: 0,0:06:47.79,0:06:49.37,EN,,0,0,0,,Or n, standing for a number.
Dialogue: 0,0:06:50.04,0:06:52.25,EN,,0,0,0,,Or e, standing for an empty list.
Dialogue: 0,0:06:54.81,0:06:55.83,EN,,0,0,0,,The end of the list.
Dialogue: 0,0:06:57.02,0:06:58.59,EN,,0,0,0,,And so if we wish to represent
Dialogue: 0,0:06:58.99,0:06:59.97,EN,,0,0,0,,an object like this,
Dialogue: 0,0:07:00.01,0:07:02.16,EN,,0,0,0,,the list beginning with 1, 2
Dialogue: 0,0:07:02.65,0:07:04.01,EN,,0,0,0,,and then having a 3 and a 4
Dialogue: 0,0:07:04.01,0:07:05.50,EN,,0,0,0,,and then having a 3 and a 4 as its second and third elements.
Dialogue: 0,0:07:06.43,0:07:08.83,EN,,0,0,0,,A list containing a list as its first part
Dialogue: 0,0:07:09.35,0:07:10.65,EN,,0,0,0,,and then two numbers
Dialogue: 0,0:07:10.65,0:07:12.00,EN,,0,0,0,,as a second and third parts.
Dialogue: 0,0:07:12.87,0:07:14.81,EN,,0,0,0,,Then of course we draw it sort of like this these days,
Dialogue: 0,0:07:14.84,0:07:16.67,EN,,0,0,0,,in box-and-pointer notation.
Dialogue: 0,0:07:17.32,0:07:18.00,EN,,0,0,0,,And you see,
Dialogue: 0,0:07:18.00,0:07:20.04,EN,,0,0,0,,these are the three cells
Dialogue: 0,0:07:20.25,0:07:22.01,EN,,0,0,0,,that have as their car pointer
Dialogue: 0,0:07:22.27,0:07:27.10,EN,,0,0,0,,the object which is either 1, 2 or 3 or 4.
Dialogue: 0,0:07:28.39,0:07:29.75,EN,,0,0,0,,And then of course the 1, 2,
Dialogue: 0,0:07:29.75,0:07:31.32,EN,,0,0,0,,the car of this entire structure,
Dialogue: 0,0:07:31.32,0:07:32.65,EN,,0,0,0,,is itself a substructure
Dialogue: 0,0:07:32.88,0:07:34.75,EN,,0,0,0,,which contains a sublist like that.
Dialogue: 0,0:07:35.94,0:07:37.07,EN,,0,0,0,,What I'm about to do
Dialogue: 0,0:07:37.20,0:07:39.92,EN,,0,0,0,,is put down places which are--
Dialogue: 0,0:07:39.95,0:07:41.46,EN,,0,0,0,,I'm going to assign indices.
Dialogue: 0,0:07:41.84,0:07:43.40,EN,,0,0,0,,Like this 1, over here,
Dialogue: 0,0:07:43.56,0:07:47.05,EN,,0,0,0,,represents the index of this cell.
Dialogue: 0,0:07:49.85,0:07:51.47,EN,,0,0,0,,But that pointer that we see here
Dialogue: 0,0:07:52.37,0:07:54.86,EN,,0,0,0,,is a reference to the
Dialogue: 0,0:07:55.07,0:07:57.29,EN,,0,0,0,,pair of pigeonholes in the cars and the cdrs
Dialogue: 0,0:07:57.40,0:07:58.67,EN,,0,0,0,,that are labeled by 1
Dialogue: 0,0:07:58.76,0:08:00.33,EN,,0,0,0,,in my linear memory down here.
Dialogue: 0,0:08:02.00,0:08:04.06,EN,,0,0,0,,So if I wish to impose this structure
Dialogue: 0,0:08:04.16,0:08:05.26,EN,,0,0,0,,on my linear memory,
Dialogue: 0,0:08:05.85,0:08:07.52,EN,,0,0,0,,what I do is I say, oh yes,
Dialogue: 0,0:08:07.52,0:08:11.88,EN,,0,0,0,,why don't we drop this into cell 1?
Dialogue: 0,0:08:11.95,0:08:12.66,EN,,0,0,0,,Well I said, I pick 1.
Dialogue: 0,0:08:12.66,0:08:13.85,EN,,0,0,0,,There's 1. OK?
Dialogue: 0,0:08:14.27,0:08:16.22,EN,,0,0,0,,And that says that its car,
Dialogue: 0,0:08:16.22,0:08:17.74,EN,,0,0,0,,I'm going to assign it to be a pair.
Dialogue: 0,0:08:17.95,0:08:18.72,EN,,0,0,0,,It's a pair,
Dialogue: 0,0:08:20.02,0:08:21.55,EN,,0,0,0,,which is in index 5.
Dialogue: 0,0:08:22.59,0:08:23.90,EN,,0,0,0,,And the cdr,
Dialogue: 0,0:08:23.90,0:08:25.13,EN,,0,0,0,,which is this one over here,
Dialogue: 0,0:08:25.39,0:08:26.13,EN,,0,0,0,,is a pair
Dialogue: 0,0:08:26.13,0:08:27.70,EN,,0,0,0,,which I'm going to stick into place 2.
Dialogue: 0,0:08:28.34,0:08:28.98,EN,,0,0,0,,p2.
Dialogue: 0,0:08:30.89,0:08:32.95,EN,,0,0,0,,And take a look at p2.
Dialogue: 0,0:08:32.95,0:08:34.72,EN,,0,0,0,,Oh yes, well p2 is a thing
Dialogue: 0,0:08:34.90,0:08:37.22,EN,,0,0,0,,whose car is the number 3,
Dialogue: 0,0:08:37.34,0:08:38.64,EN,,0,0,0,,so as you see, an n3.
Dialogue: 0,0:08:39.52,0:08:41.52,EN,,0,0,0,,And whose cdr, over here,
Dialogue: 0,0:08:41.72,0:08:43.40,EN,,0,0,0,,is a pair,
Dialogue: 0,0:08:43.97,0:08:45.81,EN,,0,0,0,,which lives in place 4.
Dialogue: 0,0:08:46.64,0:08:47.79,EN,,0,0,0,,So that's what this p4 is.
Dialogue: 0,0:08:48.65,0:08:51.16,EN,,0,0,0,,p4 is a number
Dialogue: 0,0:08:51.85,0:08:53.87,EN,,0,0,0,,whose value is 4 in its car
Dialogue: 0,0:08:54.60,0:08:55.65,EN,,0,0,0,,and whose cdr
Dialogue: 0,0:08:55.84,0:08:58.48,EN,,0,0,0,,is an empty list right there.
Dialogue: 0,0:08:59.17,0:08:59.90,EN,,0,0,0,,And that ends it.
Dialogue: 0,0:09:00.69,0:09:04.57,EN,,0,0,0,,So this is the traditional way of representing
Dialogue: 0,0:09:04.90,0:09:09.55,EN,,0,0,0,,this kind of binary tree in a linear memory.
Dialogue: 0,0:09:11.62,0:09:15.10,EN,,0,0,0,,Now the next question, of course,
Dialogue: 0,0:09:15.10,0:09:16.36,EN,,0,0,0,,that we might want to worry about
Dialogue: 0,0:09:16.60,0:09:18.19,EN,,0,0,0,,is just a little bit of implementation.
Dialogue: 0,0:09:18.44,0:09:20.33,EN,,0,0,0,,That means that when I write procedures
Dialogue: 0,0:09:20.36,0:09:23.62,EN,,0,0,0,,of the form assigned a,
Dialogue: 0,0:09:24.54,0:09:27.10,EN,,0,0,0,,lines of register machine code
Dialogue: 0,0:09:27.21,0:09:30.14,EN,,0,0,0,,of the form assigned a, the car of fetch of b,
Dialogue: 0,0:09:30.84,0:09:31.85,EN,,0,0,0,,what I really mean
Dialogue: 0,0:09:31.97,0:09:37.10,EN,,0,0,0,,is addressing these elements.
Dialogue: 0,0:09:38.74,0:09:40.25,EN,,0,0,0,,And so we're going to think of that as
Dialogue: 0,0:09:40.68,0:09:42.94,EN,,0,0,0,,a abbreviation for it.
Dialogue: 0,0:09:44.47,0:09:46.33,EN,,0,0,0,,Now of course in order to write that down
Dialogue: 0,0:09:46.35,0:09:48.59,EN,,0,0,0,,I'm going to introduce some sort of a structure
Dialogue: 0,0:09:48.62,0:09:49.42,EN,,0,0,0,,called a vector.
Dialogue: 0,0:09:52.12,0:09:53.31,EN,,0,0,0,,And we're going to have something which will
Dialogue: 0,0:09:53.48,0:09:54.54,EN,,0,0,0,,reference a vector,
Dialogue: 0,0:09:56.84,0:09:58.51,EN,,0,0,0,,just so we can write it down.
Dialogue: 0,0:09:58.71,0:10:00.22,EN,,0,0,0,,Which takes the name of the vector,
Dialogue: 0,0:10:01.02,0:10:03.97,EN,,0,0,0,,or the-- I don't think that name is the right word.
Dialogue: 0,0:10:03.97,0:10:09.40,EN,,0,0,0,,Which takes the vector and the index,
Dialogue: 0,0:10:11.20,0:10:13.05,EN,,0,0,0,,and I have to have a way of setting one of those
Dialogue: 0,0:10:13.10,0:10:14.27,EN,,0,0,0,,with something called a vector set,
Dialogue: 0,0:10:14.65,0:10:15.60,EN,,0,0,0,,I don't really care.
Dialogue: 0,0:10:16.28,0:10:17.55,EN,,0,0,0,,But let's look, for example,
Dialogue: 0,0:10:18.11,0:10:20.42,EN,,0,0,0,,at then that kind of implementation
Dialogue: 0,0:10:21.25,0:10:23.18,EN,,0,0,0,,of car and cdr.
Dialogue: 0,0:10:26.47,0:10:28.41,EN,,0,0,0,,So for example if I happen to have
Dialogue: 0,0:10:28.88,0:10:30.80,EN,,0,0,0,,a register b,
Dialogue: 0,0:10:31.15,0:10:34.64,EN,,0,0,0,,which contains the type index of a pair,
Dialogue: 0,0:10:35.95,0:10:38.80,EN,,0,0,0,,and therefore it is the pointer to a pair,
Dialogue: 0,0:10:39.35,0:10:40.85,EN,,0,0,0,,then I could take the car of that and
Dialogue: 0,0:10:41.55,0:10:44.11,EN,,0,0,0,,OK if I-- write this down-- I might put that in register a.
Dialogue: 0,0:10:44.49,0:10:46.86,EN,,0,0,0,,What that really is is a representation of
Dialogue: 0,0:10:47.37,0:10:50.19,EN,,0,0,0,,the assign to a,
Dialogue: 0,0:10:50.19,0:10:51.92,EN,,0,0,0,,the value of vector reffing--
Dialogue: 0,0:10:52.80,0:10:55.24,EN,,0,0,0,,or array indexing, if you will-- or something,
Dialogue: 0,0:10:55.42,0:10:57.63,EN,,0,0,0,,the cars object--
Dialogue: 0,0:10:58.40,0:11:00.92,EN,,0,0,0,,whatever that is-- with the index, b.
Dialogue: 0,0:11:02.65,0:11:03.63,EN,,0,0,0,,And similarly for cdr.
Dialogue: 0,0:11:04.10,0:11:05.72,EN,,0,0,0,,And we can do the same thing
Dialogue: 0,0:11:05.90,0:11:08.32,EN,,0,0,0,,for assignment to data structures,
Dialogue: 0,0:11:08.92,0:11:10.92,EN,,0,0,0,,If we need to do that sort of things at all.
Dialogue: 0,0:11:11.84,0:11:13.80,EN,,0,0,0,,It's not too hard to build that.
Dialogue: 0,0:11:14.58,0:11:15.72,EN,,0,0,0,,Well now the next question is
Dialogue: 0,0:11:15.72,0:11:17.00,EN,,0,0,0,,how are we going to do allocation.
Dialogue: 0,0:11:18.01,0:11:20.13,EN,,0,0,0,,And every so often I say I want a cons.
Dialogue: 0,0:11:21.40,0:11:23.42,EN,,0,0,0,,Now conses don't grow on trees.
Dialogue: 0,0:11:23.79,0:11:24.81,EN,,0,0,0,,Or maybe they should.
Dialogue: 0,0:11:25.34,0:11:26.56,EN,,0,0,0,,But I have to have some way
Dialogue: 0,0:11:26.70,0:11:28.97,EN,,0,0,0,,I have to have some way of getting the next one.
Dialogue: 0,0:11:29.98,0:11:31.47,EN,,0,0,0,,I have to have some idea of
Dialogue: 0,0:11:31.47,0:11:33.04,EN,,0,0,0,,if their memory is unused
Dialogue: 0,0:11:33.69,0:11:35.05,EN,,0,0,0,,that I might want to allocate from.
Dialogue: 0,0:11:35.63,0:11:37.38,EN,,0,0,0,,And there are many schemes for doing this.
Dialogue: 0,0:11:37.38,0:11:39.07,EN,,0,0,0,,And the particular thing I'm showing you right now
Dialogue: 0,0:11:39.23,0:11:40.45,EN,,0,0,0,,is not essential.
Dialogue: 0,0:11:42.10,0:11:43.18,EN,,0,0,0,,However it's convenient
Dialogue: 0,0:11:43.20,0:11:44.44,EN,,0,0,0,,and has been done many times.
Dialogue: 0,0:11:44.60,0:11:47.20,EN,,0,0,0,,It's one schemes called the free list allocation scheme.
Dialogue: 0,0:11:47.66,0:11:48.68,EN,,0,0,0,,What that means is
Dialogue: 0,0:11:48.68,0:11:51.12,EN,,0,0,0,,that all of the free memory that there is in the world
Dialogue: 0,0:11:51.55,0:11:53.08,EN,,0,0,0,,is linked together in a linked list,
Dialogue: 0,0:11:54.55,0:11:56.22,EN,,0,0,0,,just like all the other stuff.
Dialogue: 0,0:11:56.96,0:11:59.07,EN,,0,0,0,,And whenever you need a free cell
Dialogue: 0,0:11:59.07,0:12:00.12,EN,,0,0,0,,to make a new cons,
Dialogue: 0,0:12:00.95,0:12:02.26,EN,,0,0,0,,you grab the first one
Dialogue: 0,0:12:02.26,0:12:03.82,EN,,0,0,0,,make the free list be the cdr of it,
Dialogue: 0,0:12:04.32,0:12:05.55,EN,,0,0,0,,and then allocate that.
Dialogue: 0,0:12:06.03,0:12:08.32,EN,,0,0,0,,And so what that looks like is something like this.
Dialogue: 0,0:12:09.53,0:12:13.32,EN,,0,0,0,,Here we have the free list
Dialogue: 0,0:12:13.95,0:12:16.81,EN,,0,0,0,,starting in 6.
Dialogue: 0,0:12:18.51,0:12:23.47,EN,,0,0,0,,And what that is is a pointer-off to say 8.
Dialogue: 0,0:12:24.86,0:12:25.62,EN,,0,0,0,,So what it says is,
Dialogue: 0,0:12:25.62,0:12:26.55,EN,,0,0,0,,this one is free
Dialogue: 0,0:12:26.55,0:12:27.95,EN,,0,0,0,,and the next one is an 8.
Dialogue: 0,0:12:28.87,0:12:29.88,EN,,0,0,0,,This one is free
Dialogue: 0,0:12:30.04,0:12:32.08,EN,,0,0,0,,and the next one is in 3,
Dialogue: 0,0:12:32.32,0:12:33.45,EN,,0,0,0,,the next one that's free.
Dialogue: 0,0:12:33.93,0:12:34.95,EN,,0,0,0,,That one's free
Dialogue: 0,0:12:35.04,0:12:37.68,EN,,0,0,0,,and the next one is in 0.
Dialogue: 0,0:12:37.87,0:12:38.49,EN,,0,0,0,,That one's free
Dialogue: 0,0:12:38.52,0:12:39.82,EN,,0,0,0,,and the next one's in 15.
Dialogue: 0,0:12:40.94,0:12:41.84,EN,,0,0,0,,Something like that.
Dialogue: 0,0:12:42.78,0:12:44.64,EN,,0,0,0,,We can imagine having such a structure.
Dialogue: 0,0:12:46.40,0:12:48.03,EN,,0,0,0,,Given that we have something like that,
Dialogue: 0,0:12:49.45,0:12:50.92,EN,,0,0,0,,then it's possible to
Dialogue: 0,0:12:50.92,0:12:52.22,EN,,0,0,0,,just get one when you need it.
Dialogue: 0,0:12:53.82,0:12:56.46,EN,,0,0,0,,And so a program for doing cons,
Dialogue: 0,0:12:57.45,0:12:59.13,EN,,0,0,0,,this is what cons might turn into.
Dialogue: 0,0:12:59.32,0:13:02.57,EN,,0,0,0,,To assign to a register A the result of cons-ing,
Dialogue: 0,0:13:02.95,0:13:05.82,EN,,0,0,0,,a B onto C,
Dialogue: 0,0:13:06.20,0:13:09.04,EN,,0,0,0,,the value in this containing B and the value containing C,
Dialogue: 0,0:13:09.27,0:13:10.52,EN,,0,0,0,,what we have to do is
Dialogue: 0,0:13:10.56,0:13:12.24,EN,,0,0,0,,get the current tail ahead of the freelist,
Dialogue: 0,0:13:12.47,0:13:14.30,EN,,0,0,0,,make the free list be its cdr.
Dialogue: 0,0:13:15.64,0:13:18.33,EN,,0,0,0,,Then we have to change the cars
Dialogue: 0,0:13:18.41,0:13:22.49,EN,,0,0,0,,to be the thing we're making up to be in A
Dialogue: 0,0:13:23.13,0:13:25.45,EN,,0,0,0,,to be the B, the thing in B.
Dialogue: 0,0:13:25.90,0:13:28.65,EN,,0,0,0,,And we have to make change the cdrs of
Dialogue: 0,0:13:29.20,0:13:31.72,EN,,0,0,0,,the thing that's in A to be C.
Dialogue: 0,0:13:33.20,0:13:34.76,EN,,0,0,0,,And then what we have in A
Dialogue: 0,0:13:34.78,0:13:36.65,EN,,0,0,0,,is the right new frob, whatever it is.
Dialogue: 0,0:13:36.81,0:13:37.92,EN,,0,0,0,,The object that we want.
Dialogue: 0,0:13:40.47,0:13:42.50,EN,,0,0,0,,Now there's a little bit of
Dialogue: 0,0:13:42.50,0:13:43.97,EN,,0,0,0,,a cheat here that I haven't told you about,
Dialogue: 0,0:13:43.97,0:13:45.32,EN,,0,0,0,,which is somewhere around here
Dialogue: 0,0:13:45.53,0:13:47.32,EN,,0,0,0,,I haven't set the type of the thing that I've
Dialogue: 0,0:13:48.45,0:13:50.48,EN,,0,0,0,,the type of the thing
Dialogue: 0,0:13:50.51,0:13:51.87,EN,,0,0,0,,that I'm cons-ing up to be a pair,
Dialogue: 0,0:13:52.30,0:13:53.05,EN,,0,0,0,,and I ought to.
Dialogue: 0,0:13:53.51,0:13:56.57,EN,,0,0,0,,So there should be some sort of bits here are being set,
Dialogue: 0,0:13:56.60,0:13:57.76,EN,,0,0,0,,and I just haven't written that down.
Dialogue: 0,0:13:59.81,0:14:00.86,EN,,0,0,0,,We could have arranged it, of course,
Dialogue: 0,0:14:00.89,0:14:02.45,EN,,0,0,0,,for the free list to be made out of pairs.
Dialogue: 0,0:14:03.10,0:14:04.88,EN,,0,0,0,,And so then there's no problem with that.
Dialogue: 0,0:14:06.43,0:14:07.74,EN,,0,0,0,,But that sort of--
Dialogue: 0,0:14:07.82,0:14:09.92,EN,,0,0,0,,again, an inessential detail in a way
Dialogue: 0,0:14:10.22,0:14:12.88,EN,,0,0,0,,some particular programmer or architect
Dialogue: 0,0:14:12.92,0:14:14.27,EN,,0,0,0,,or whatever might manufacture
Dialogue: 0,0:14:14.33,0:14:16.68,EN,,0,0,0,,his machine or Lisp system.
Dialogue: 0,0:14:17.54,0:14:18.71,EN,,0,0,0,,So for example,
Dialogue: 0,0:14:19.07,0:14:20.24,EN,,0,0,0,,just looking at this,
Dialogue: 0,0:14:20.65,0:14:23.45,EN,,0,0,0,,to allocate
Dialogue: 0,0:14:23.55,0:14:26.83,EN,,0,0,0,,given that I had already the structure that you saw before,
Dialogue: 0,0:14:27.21,0:14:30.26,EN,,0,0,0,,supposing I wanted to allocate a new cell,
Dialogue: 0,0:14:30.55,0:14:36.61,EN,,0,0,0,,which is going to be representation of list one, one, two,
Dialogue: 0,0:14:37.24,0:14:39.87,EN,,0,0,0,,where already one two was the car
Dialogue: 0,0:14:40.28,0:14:42.16,EN,,0,0,0,,of the list we were playing with before.
Dialogue: 0,0:14:43.43,0:14:44.45,EN,,0,0,0,,Well that's not so hard.
Dialogue: 0,0:14:44.78,0:14:46.20,EN,,0,0,0,,I stored that one in one,
Dialogue: 0,0:14:46.20,0:14:49.17,EN,,0,0,0,,so p1 one is the representation of this.
Dialogue: 0,0:14:49.53,0:14:50.83,EN,,0,0,0,,This is p5.
Dialogue: 0,0:14:51.67,0:14:53.51,EN,,0,0,0,,That's going to be the cdr of this.
Dialogue: 0,0:14:54.07,0:14:55.52,EN,,0,0,0,,Now we're going to pull something off the free list,
Dialogue: 0,0:14:55.52,0:14:57.30,EN,,0,0,0,,but remember the free list started at six.
Dialogue: 0,0:14:57.78,0:15:00.18,EN,,0,0,0,,The new free list after this allocation is eight,
Dialogue: 0,0:15:00.60,0:15:02.55,EN,,0,0,0,,a free list beginning at eight.
Dialogue: 0,0:15:02.89,0:15:03.52,EN,,0,0,0,,And of course
Dialogue: 0,0:15:03.72,0:15:06.04,EN,,0,0,0,,in six now we have a number one,
Dialogue: 0,0:15:06.15,0:15:07.10,EN,,0,0,0,,which is what we wanted,
Dialogue: 0,0:15:07.39,0:15:11.56,EN,,0,0,0,,with its cdr being the pair starting in location five.
Dialogue: 0,0:15:13.33,0:15:14.50,EN,,0,0,0,,And that's no big deal.
Dialogue: 0,0:15:16.81,0:15:20.45,EN,,0,0,0,,So the only problem really remaining here is,
Dialogue: 0,0:15:21.00,0:15:23.40,EN,,0,0,0,,well, I don't have an infinitely large memory.
Dialogue: 0,0:15:25.08,0:15:26.66,EN,,0,0,0,,If I do this for a little while,
Dialogue: 0,0:15:27.25,0:15:28.00,EN,,0,0,0,,say, for example,
Dialogue: 0,0:15:28.01,0:15:30.14,EN,,0,0,0,,supposing it takes me a microsecond to do a cons,
Dialogue: 0,0:15:30.60,0:15:32.97,EN,,0,0,0,,and I have a million cons memory
Dialogue: 0,0:15:33.60,0:15:35.27,EN,,0,0,0,,then I'm only going to run out in a second,
Dialogue: 0,0:15:35.95,0:15:37.00,EN,,0,0,0,,and that's pretty bad.
Dialogue: 0,0:15:38.00,0:15:40.62,EN,,0,0,0,,So what we do to prevent that disaster,
Dialogue: 0,0:15:40.62,0:15:42.19,EN,,0,0,0,,that ecological disaster,
Dialogue: 0,0:15:42.60,0:15:44.30,EN,,0,0,0,,talk about right after questions.
Dialogue: 0,0:15:44.30,0:15:45.26,EN,,0,0,0,,Are there any questions?
Dialogue: 0,0:15:51.50,0:15:51.69,EN,,0,0,0,,Yes.
Dialogue: 0,0:15:52.03,0:15:54.67,EN,,0,0,0,,AUDIENCE: In the environment diagrams that we were drawing
Dialogue: 0,0:15:54.67,0:15:58.25,EN,,0,0,0,,we would use the body of procedures,
Dialogue: 0,0:15:58.25,0:16:00.67,EN,,0,0,0,,and you would eventually wind up with
Dialogue: 0,0:16:00.80,0:16:03.60,EN,,0,0,0,,things that were no longer useful in that structure.
Dialogue: 0,0:16:03.60,0:16:04.16,EN,,0,0,0,,PROFESSOR: Yes, madam.
Dialogue: 0,0:16:04.93,0:16:06.67,EN,,0,0,0,,AUDIENCE: How is that represented?
Dialogue: 0,0:16:06.76,0:16:08.75,EN,,0,0,0,,PROFESSOR: There's two problems here. OK?
Dialogue: 0,0:16:09.18,0:16:10.25,EN,,0,0,0,,One you were asking
Dialogue: 0,0:16:10.25,0:16:13.43,EN,,0,0,0,,is that material becomes useless.
Dialogue: 0,0:16:13.87,0:16:14.92,EN,,0,0,0,,We'll talk about that in a second.
Dialogue: 0,0:16:14.92,0:16:17.00,EN,,0,0,0,,That has to do with how to prevent ecological disasters.
Dialogue: 0,0:16:17.63,0:16:19.20,EN,,0,0,0,,Right? If I make a lot of garbage
Dialogue: 0,0:16:19.20,0:16:21.39,EN,,0,0,0,,I have to somehow be able to clean up after myself.
Dialogue: 0,0:16:21.82,0:16:22.97,EN,,0,0,0,,And we'll talk about that in a second.
Dialogue: 0,0:16:23.43,0:16:24.57,EN,,0,0,0,,The other question you're asking
Dialogue: 0,0:16:24.57,0:16:27.21,EN,,0,0,0,,is how you represent the environments, I think.
Dialogue: 0,0:16:27.28,0:16:27.60,EN,,0,0,0,,AUDIENCE: Yes.
Dialogue: 0,0:16:27.60,0:16:28.19,EN,,0,0,0,,PROFESSOR: OK.
Dialogue: 0,0:16:28.19,0:16:30.62,EN,,0,0,0,,And the environment structures can be represented in arbitrary ways.
Dialogue: 0,0:16:30.92,0:16:31.78,EN,,0,0,0,,There are lots of them.
Dialogue: 0,0:16:31.78,0:16:33.34,EN,,0,0,0,,I mean, here I'm just telling you about list cells.
Dialogue: 0,0:16:33.63,0:16:34.92,EN,,0,0,0,,Of course every real system
Dialogue: 0,0:16:34.92,0:16:36.72,EN,,0,0,0,,has vectors of arbitrary length
Dialogue: 0,0:16:36.72,0:16:39.15,EN,,0,0,0,,as well as the vectors of length, too,
Dialogue: 0,0:16:39.31,0:16:40.51,EN,,0,0,0,,which represent list cells.
Dialogue: 0,0:16:41.08,0:16:44.90,EN,,0,0,0,,And the environment structures that one uses in a
Dialogue: 0,0:16:44.90,0:16:46.99,EN,,0,0,0,,professionally written Lisp system
Dialogue: 0,0:16:47.30,0:16:49.69,EN,,0,0,0,,tend to be vectors
Dialogue: 0,0:16:49.69,0:16:51.92,EN,,0,0,0,,which contain a number of elements approximately
Dialogue: 0,0:16:51.92,0:16:54.60,EN,,0,0,0,,equal to the number of arguments-- a little bit more
Dialogue: 0,0:16:55.35,0:16:56.86,EN,,0,0,0,,because you need sort of glue.
Dialogue: 0,0:16:57.40,0:17:00.74,EN,,0,0,0,,OK? So remember, the environment is in a frame.
Dialogue: 0,0:17:00.74,0:17:03.98,EN,,0,0,0,,The frames are constructed by applying a procedure.
Dialogue: 0,0:17:03.98,0:17:04.78,EN,,0,0,0,,In doing so,
Dialogue: 0,0:17:04.80,0:17:07.60,EN,,0,0,0,,an allocation is made of a place
Dialogue: 0,0:17:07.64,0:17:11.27,EN,,0,0,0,,which is the number of arguments long plus some glue
Dialogue: 0,0:17:11.27,0:17:12.71,EN,,0,0,0,,that gets linked into a chain.
Dialogue: 0,0:17:13.32,0:17:15.66,EN,,0,0,0,,It's just like algol at that level.
Dialogue: 0,0:17:19.81,0:17:20.72,EN,,0,0,0,,There any other questions?
Dialogue: 0,0:17:23.70,0:17:23.92,EN,,0,0,0,,OK.
Dialogue: 0,0:17:23.92,0:17:25.55,EN,,0,0,0,,Thank you, and let's take a short break.
Dialogue: 0,0:17:26.35,0:17:45.48,EN,,0,0,0,,[JESU, JOY OF MAN'S DESIRING]
Dialogue: 0,0:17:45.53,0:17:50.01,EN,,0,0,0,,The Structure And Interpretation of Computer Programs
Dialogue: 0,0:17:55.74,0:17:59.04,EN,,0,0,0,,By: Prof. Harold Abelson && Sussman Jay Sussman
Dialogue: 0,0:17:59.13,0:18:04.22,EN,,0,0,0,,The Structure And Interpretation of Computer Programs
Dialogue: 0,0:18:04.32,0:18:09.87,EN,,0,0,0,,Storage Allocation & Garbage Collection
Dialogue: 0,0:18:12.27,0:18:14.24,EN,,0,0,0,,PROFESSOR: Well, as I just said,
Dialogue: 0,0:18:14.55,0:18:15.50,EN,,0,0,0,,computer memories
Dialogue: 0,0:18:15.82,0:18:17.96,EN,,0,0,0,,supplied by the semiconductor manufacturers
Dialogue: 0,0:18:18.16,0:18:19.00,EN,,0,0,0,,are finite.
Dialogue: 0,0:18:19.42,0:18:20.40,EN,,0,0,0,,And that's quite a pity.
Dialogue: 0,0:18:21.62,0:18:23.35,EN,,0,0,0,,It might not always be that way.
Dialogue: 0,0:18:24.03,0:18:25.40,EN,,0,0,0,,Just for a quick calculation,
Dialogue: 0,0:18:25.44,0:18:28.86,EN,,0,0,0,,you can see that it's possible that if memory's
Dialogue: 0,0:18:28.86,0:18:30.80,EN,,0,0,0,,prices keep going at the rate they're going
Dialogue: 0,0:18:31.22,0:18:33.68,EN,,0,0,0,,that if you still took a microsecond second to do a cons,
Dialogue: 0,0:18:34.42,0:18:35.90,EN,,0,0,0,,then-- first of all, everybody
Dialogue: 0,0:18:35.90,0:18:37.07,EN,,0,0,0,,should know that there's about pi
Dialogue: 0,0:18:37.10,0:18:38.86,EN,,0,0,0,,times ten to the seventh seconds in a year.
Dialogue: 0,0:18:39.45,0:18:41.12,EN,,0,0,0,,And so that would be
Dialogue: 0,0:18:41.50,0:18:42.73,EN,,0,0,0,,ten to the seventh plus ten to the sixth
Dialogue: 0,0:18:42.73,0:18:43.94,EN,,0,0,0,,is ten to the thirteenth.
Dialogue: 0,0:18:43.94,0:18:45.50,EN,,0,0,0,,So there's maybe ten to the fourteenth conses
Dialogue: 0,0:18:45.50,0:18:46.80,EN,,0,0,0,,in the life of a machine.
Dialogue: 0,0:18:47.52,0:18:49.40,EN,,0,0,0,,If there was ten to the fourteenth words of memory
Dialogue: 0,0:18:49.68,0:18:50.57,EN,,0,0,0,,on your machine,
Dialogue: 0,0:18:51.20,0:18:52.16,EN,,0,0,0,,you'd never run out.
Dialogue: 0,0:18:53.04,0:18:53.85,EN,,0,0,0,,OK so that will be,
Dialogue: 0,0:18:53.95,0:18:55.76,EN,,0,0,0,,And that's not completely unreasonable.
Dialogue: 0,0:18:56.31,0:18:58.46,EN,,0,0,0,,Ten to the fourteenth is not a very large number.
Dialogue: 0,0:19:01.45,0:19:04.70,EN,,0,0,0,,Even for... I don't think it is.
Dialogue: 0,0:19:05.18,0:19:07.39,EN,,0,0,0,,But then again I like to play with astronomy.
Dialogue: 0,0:19:07.93,0:19:11.04,EN,,0,0,0,,It's at least ten to the eighteenth centimeters
Dialogue: 0,0:19:11.10,0:19:12.45,EN,,0,0,0,,between us and the nearest star.
Dialogue: 0,0:19:12.93,0:19:18.85,EN,,0,0,0,,But the thing I'm about to worry about is,
Dialogue: 0,0:19:19.15,0:19:21.27,EN,,0,0,0,,at least in the current economic state of affairs,
Dialogue: 0,0:19:21.27,0:19:23.57,EN,,0,0,0,,ten to the fourteenth pieces of memory is expensive.
Dialogue: 0,0:19:24.20,0:19:26.62,EN,,0,0,0,,And so I suppose what we have to do
Dialogue: 0,0:19:26.81,0:19:28.51,EN,,0,0,0,,is make do with much smaller memories.
Dialogue: 0,0:19:30.02,0:19:30.59,EN,,0,0,0,,Now
Dialogue: 0,0:19:32.84,0:19:35.07,EN,,0,0,0,,in general we want to have an illusion of infinity.
Dialogue: 0,0:19:35.80,0:19:37.22,EN,,0,0,0,,All we need to do is arrange it
Dialogue: 0,0:19:37.82,0:19:39.68,EN,,0,0,0,,so that whenever you look, the thing is there.
Dialogue: 0,0:19:41.92,0:19:45.55,EN,,0,0,0,,That's, that's really an important idea.
Dialogue: 0,0:19:49.54,0:19:51.97,EN,,0,0,0,,A person or a computer lives only a finite amount of time
Dialogue: 0,0:19:52.32,0:19:54.59,EN,,0,0,0,,and can only take a finite number of looks at something.
Dialogue: 0,0:19:55.28,0:19:57.37,EN,,0,0,0,,And so you really only need a finite amount of stuff.
Dialogue: 0,0:19:58.19,0:19:59.00,EN,,0,0,0,,But you have to arrange it
Dialogue: 0,0:19:59.00,0:20:00.38,EN,,0,0,0,,so no matter how much there is,
Dialogue: 0,0:20:00.77,0:20:03.46,EN,,0,0,0,,how much you really claim there is,
Dialogue: 0,0:20:03.46,0:20:04.74,EN,,0,0,0,,there's always enough stuff
Dialogue: 0,0:20:04.74,0:20:06.90,EN,,0,0,0,,so that when you take a look, it's there.
Dialogue: 0,0:20:06.90,0:20:08.15,EN,,0,0,0,,And so you only need a finite amount.
Dialogue: 0,0:20:08.75,0:20:09.94,EN,,0,0,0,,But let's see.
Dialogue: 0,0:20:11.63,0:20:13.32,EN,,0,0,0,,One problem is, as was brought up,
Dialogue: 0,0:20:13.92,0:20:15.45,EN,,0,0,0,,that there are possible ways
Dialogue: 0,0:20:15.72,0:20:17.84,EN,,0,0,0,,that there is lots of stuff
Dialogue: 0,0:20:17.88,0:20:19.16,EN,,0,0,0,,that we make that we don't need.
Dialogue: 0,0:20:19.41,0:20:21.81,EN,,0,0,0,,And we could recycle the material out of which its made.
Dialogue: 0,0:20:22.62,0:20:23.53,EN,,0,0,0,,An example
Dialogue: 0,0:20:24.15,0:20:25.79,EN,,0,0,0,,for is, is the fact
Dialogue: 0,0:20:25.79,0:20:28.40,EN,,0,0,0,,when we're building environment structures,
Dialogue: 0,0:20:28.40,0:20:30.47,EN,,0,0,0,,and we do so every time we call a procedure.
Dialogue: 0,0:20:30.47,0:20:32.56,EN,,0,0,0,,We have built in it a environment frame.
Dialogue: 0,0:20:33.14,0:20:34.03,EN,,0,0,0,,That environment frame
Dialogue: 0,0:20:34.22,0:20:36.07,EN,,0,0,0,,doesn't necessarily have a very long lifetime.
Dialogue: 0,0:20:36.73,0:20:38.69,EN,,0,0,0,,Its lifetime, meaning its usefulness,
Dialogue: 0,0:20:39.42,0:20:42.60,EN,,0,0,0,,may exist only over the invocation of the procedure.
Dialogue: 0,0:20:42.85,0:20:45.27,EN,,0,0,0,,Or if the procedure exports another procedure
Dialogue: 0,0:20:45.27,0:20:46.67,EN,,0,0,0,,by returning it as a value
Dialogue: 0,0:20:46.87,0:20:48.52,EN,,0,0,0,,and that procedure is defined inside of it,
Dialogue: 0,0:20:48.52,0:20:50.80,EN,,0,0,0,,well then the lifetime of the
Dialogue: 0,0:20:51.07,0:20:53.39,EN,,0,0,0,,frame of the outer procedure still is
Dialogue: 0,0:20:53.50,0:20:56.12,EN,,0,0,0,,only the lifetime of the procedure
Dialogue: 0,0:20:57.02,0:20:57.90,EN,,0,0,0,,which was exported.
Dialogue: 0,0:20:58.53,0:20:59.57,EN,,0,0,0,,And so ultimately,
Dialogue: 0,0:20:59.57,0:21:00.97,EN,,0,0,0,,a lot of that is garbage.
Dialogue: 0,0:21:01.96,0:21:04.10,EN,,0,0,0,,There are other ways of producing garbage as well.
Dialogue: 0,0:21:05.37,0:21:06.67,EN,,0,0,0,,Users produce garbage.
Dialogue: 0,0:21:07.24,0:21:08.07,EN,,0,0,0,,An example of
Dialogue: 0,0:21:08.07,0:21:10.22,EN,,0,0,0,,user garbage is something like this.
Dialogue: 0,0:21:10.93,0:21:14.00,EN,,0,0,0,,If we write a program to, for example,
Dialogue: 0,0:21:14.00,0:21:15.80,EN,,0,0,0,,append two lists together,
Dialogue: 0,0:21:16.05,0:21:18.14,EN,,0,0,0,,well one way to do it is to
Dialogue: 0,0:21:18.32,0:21:21.37,EN,,0,0,0,,reverse the first list onto the empty list
Dialogue: 0,0:21:21.37,0:21:23.72,EN,,0,0,0,,and reverse that onto the second list.
Dialogue: 0,0:21:24.70,0:21:26.92,EN,,0,0,0,,Now that's not terribly bad way of doing it.
Dialogue: 0,0:21:28.16,0:21:28.85,EN,,0,0,0,,And however,
Dialogue: 0,0:21:28.85,0:21:30.09,EN,,0,0,0,,the intermediate result,
Dialogue: 0,0:21:30.11,0:21:32.02,EN,,0,0,0,,which is the reversal of the first list
Dialogue: 0,0:21:33.87,0:21:35.57,EN,,0,0,0,,as done by this program,
Dialogue: 0,0:21:36.70,0:21:38.52,EN,,0,0,0,,is never going to be accessed ever again
Dialogue: 0,0:21:38.52,0:21:40.56,EN,,0,0,0,,after it's copied back on to the second.
Dialogue: 0,0:21:41.01,0:21:42.23,EN,,0,0,0,,It's an intermediate result.
Dialogue: 0,0:21:43.58,0:21:45.43,EN,,0,0,0,,It's going to be hard to ever see
Dialogue: 0,0:21:46.07,0:21:48.05,EN,,0,0,0,,how anybody would ever be able to access it.
Dialogue: 0,0:21:48.60,0:21:49.84,EN,,0,0,0,,In fact, it will go away.
Dialogue: 0,0:21:51.05,0:21:52.90,EN,,0,0,0,,Now if we make a lot of garbage like that,
Dialogue: 0,0:21:52.90,0:21:54.20,EN,,0,0,0,,and we should be allowed to,
Dialogue: 0,0:21:54.80,0:21:57.29,EN,,0,0,0,,then there's got to be some way to reclaim that garbage.
Dialogue: 0,0:21:58.80,0:22:00.90,EN,,0,0,0,,Well, what I'd like to tell you about now
Dialogue: 0,0:22:01.70,0:22:03.77,EN,,0,0,0,,is a very clever technique
Dialogue: 0,0:22:04.32,0:22:07.58,EN,,0,0,0,,whereby a Lisp system
Dialogue: 0,0:22:07.95,0:22:11.21,EN,,0,0,0,,can prove a small theorem every so often
Dialogue: 0,0:22:11.29,0:22:13.50,EN,,0,0,0,,on the form the following piece of junk
Dialogue: 0,0:22:14.72,0:22:16.09,EN,,0,0,0,,will never be accessed again.
Dialogue: 0,0:22:17.41,0:22:19.80,EN,,0,0,0,,It can have no affect on the future of the computation.
Dialogue: 0,0:22:21.40,0:22:23.61,EN,,0,0,0,,It's actually based on a very simple idea.
Dialogue: 0,0:22:24.72,0:22:28.06,EN,,0,0,0,,We've designed our computers to look sort of like this.
Dialogue: 0,0:22:28.95,0:22:30.67,EN,,0,0,0,,There's some data path,
Dialogue: 0,0:22:31.87,0:22:33.40,EN,,0,0,0,,which contains the registers.
Dialogue: 0,0:22:34.92,0:22:38.04,EN,,0,0,0,,You know, there are things like exp, and env,
Dialogue: 0,0:22:39.04,0:22:42.19,EN,,0,0,0,,and val, and so on.
Dialogue: 0,0:22:42.61,0:22:44.02,EN,,0,0,0,,And there's one here called stack,
Dialogue: 0,0:22:46.02,0:22:49.45,EN,,0,0,0,,some sort which points off to a structure somewhere,
Dialogue: 0,0:22:49.50,0:22:50.22,EN,,0,0,0,,which is the stack.
Dialogue: 0,0:22:50.24,0:22:51.48,EN,,0,0,0,,And we'll worry about that in a second.
Dialogue: 0,0:22:51.64,0:22:53.62,EN,,0,0,0,,There's some finite controller,
Dialogue: 0,0:22:54.38,0:22:56.57,EN,,0,0,0,,finite state machine controller.
Dialogue: 0,0:22:56.73,0:22:59.51,EN,,0,0,0,,And there's some control signals that go this way and
Dialogue: 0,0:22:59.80,0:23:01.44,EN,,0,0,0,,predicate results that come this way,
Dialogue: 0,0:23:01.87,0:23:03.13,EN,,0,0,0,,not the interesting part.
Dialogue: 0,0:23:03.35,0:23:06.51,EN,,0,0,0,,There's some sort of structured memory,
Dialogue: 0,0:23:06.80,0:23:08.27,EN,,0,0,0,,which I just told you how to make,
Dialogue: 0,0:23:08.27,0:23:10.17,EN,,0,0,0,,which may contain a stack.
Dialogue: 0,0:23:10.46,0:23:11.48,EN,,0,0,0,,I didn't tell you how to make things
Dialogue: 0,0:23:11.48,0:23:12.43,EN,,0,0,0,,of arbitrary shape,
Dialogue: 0,0:23:12.56,0:23:13.39,EN,,0,0,0,,only pairs.
Dialogue: 0,0:23:13.60,0:23:14.20,EN,,0,0,0,,But in fact
Dialogue: 0,0:23:14.35,0:23:15.44,EN,,0,0,0,,with what I've told you can
Dialogue: 0,0:23:15.47,0:23:16.96,EN,,0,0,0,,with what I've told you can simulate a stack by a big list.
Dialogue: 0,0:23:17.77,0:23:18.85,EN,,0,0,0,,I don't plan to do that,
Dialogue: 0,0:23:18.85,0:23:20.01,EN,,0,0,0,,it's not a nice way to do it.
Dialogue: 0,0:23:20.36,0:23:22.60,EN,,0,0,0,,But we could have something like that.
Dialogue: 0,0:23:22.99,0:23:25.28,EN,,0,0,0,,We have all sorts of little data structures in here
Dialogue: 0,0:23:25.64,0:23:27.75,EN,,0,0,0,,that are hooked together in funny ways.
Dialogue: 0,0:23:30.11,0:23:32.02,EN,,0,0,0,,They connect to other things.
Dialogue: 0,0:23:32.56,0:23:33.25,EN,,0,0,0,,And so on.
Dialogue: 0,0:23:33.25,0:23:34.22,EN,,0,0,0,,And ultimately
Dialogue: 0,0:23:34.45,0:23:37.19,EN,,0,0,0,,things up there are pointers to these.
Dialogue: 0,0:23:37.19,0:23:38.87,EN,,0,0,0,,The things that are in the registers
Dialogue: 0,0:23:39.40,0:23:41.40,EN,,0,0,0,,are pointers off to the data structures
Dialogue: 0,0:23:41.44,0:23:43.08,EN,,0,0,0,,that live in this list structure memory.
Dialogue: 0,0:23:44.91,0:23:49.80,EN,,0,0,0,,Now the truth of the matter is
Dialogue: 0,0:23:51.05,0:23:52.56,EN,,0,0,0,,that the entire consciousness
Dialogue: 0,0:23:52.57,0:23:53.92,EN,,0,0,0,,of this machine is in these registers.
Dialogue: 0,0:23:55.76,0:23:58.51,EN,,0,0,0,,There is no possible way that the machine,
Dialogue: 0,0:23:58.75,0:24:01.07,EN,,0,0,0,,if done correctly, if built correctly,
Dialogue: 0,0:24:01.37,0:24:03.41,EN,,0,0,0,,can access anything in this list structure memory
Dialogue: 0,0:24:04.57,0:24:07.05,EN,,0,0,0,,unless the thing in that list structure memory is
Dialogue: 0,0:24:08.09,0:24:10.88,EN,,0,0,0,,is connected by a sequence of data structures
Dialogue: 0,0:24:11.64,0:24:13.06,EN,,0,0,0,,to the registers.
Dialogue: 0,0:24:15.07,0:24:15.98,EN,,0,0,0,,If it's accessible
Dialogue: 0,0:24:16.22,0:24:18.31,EN,,0,0,0,,by legitimate data structure selectors
Dialogue: 0,0:24:19.08,0:24:21.12,EN,,0,0,0,,from the pointers that are stored in these registers.
Dialogue: 0,0:24:22.28,0:24:24.46,EN,,0,0,0,,Things like array references, perhaps.
Dialogue: 0,0:24:24.94,0:24:27.92,EN,,0,0,0,,Or cons cell references, cars and cdrs.
Dialogue: 0,0:24:29.08,0:24:30.95,EN,,0,0,0,,But I can't just talk about a random place in this memory,
Dialogue: 0,0:24:30.95,0:24:31.95,EN,,0,0,0,,because I can't get to it.
Dialogue: 0,0:24:32.74,0:24:34.90,EN,,0,0,0,,These are being arbitrary names I'm not allowed to count,
Dialogue: 0,0:24:37.00,0:24:39.16,EN,,0,0,0,,at least as I'm evaluating expressions.
Dialogue: 0,0:24:41.62,0:24:42.57,EN,,0,0,0,,If that's the case
Dialogue: 0,0:24:43.27,0:24:45.07,EN,,0,0,0,,then there's a very simple theorem to be proved.
Dialogue: 0,0:24:47.16,0:24:47.69,EN,,0,0,0,,Which is,
Dialogue: 0,0:24:47.90,0:24:50.52,EN,,0,0,0,,if I start with all lead pointers that are in all these registers
Dialogue: 0,0:24:51.16,0:24:52.55,EN,,0,0,0,,and recursively chase out,
Dialogue: 0,0:24:52.82,0:24:56.15,EN,,0,0,0,,marking all the places I can get to by selectors,
Dialogue: 0,0:24:56.90,0:24:59.40,EN,,0,0,0,,then eventually I mark everything they can be gotten to.
Dialogue: 0,0:25:00.65,0:25:02.69,EN,,0,0,0,,Anything which is not so marked is garbage
Dialogue: 0,0:25:02.69,0:25:03.75,EN,,0,0,0,,and can be recycled.
Dialogue: 0,0:25:05.56,0:25:06.20,EN,,0,0,0,,Very simple.
Dialogue: 0,0:25:07.20,0:25:09.10,EN,,0,0,0,,Cannot affect the future of the computation.
Dialogue: 0,0:25:11.18,0:25:12.84,EN,,0,0,0,,So let me show you that in a particular
Dialogue: 0,0:25:13.93,0:25:15.75,EN,,0,0,0,,in a particular example.
Dialogue: 0,0:25:17.12,0:25:19.37,EN,,0,0,0,,Now that means I'm going to have to append to my
Dialogue: 0,0:25:19.69,0:25:22.08,EN,,0,0,0,,description of the list structure a mark.
Dialogue: 0,0:25:23.64,0:25:24.89,EN,,0,0,0,,And so here, for example,
Dialogue: 0,0:25:25.37,0:25:27.28,EN,,0,0,0,,is a list structured memory.
Dialogue: 0,0:25:29.08,0:25:30.32,EN,,0,0,0,,And in this list structured memory
Dialogue: 0,0:25:30.33,0:25:31.33,EN,,0,0,0,,is a list structure
Dialogue: 0,0:25:31.33,0:25:33.95,EN,,0,0,0,,beginning in a place I'm going to call--
Dialogue: 0,0:25:35.87,0:25:36.62,EN,,0,0,0,,this is the root.
Dialogue: 0,0:25:38.59,0:25:40.12,EN,,0,0,0,,Now it doesn't really have to have a root.
Dialogue: 0,0:25:40.12,0:25:41.95,EN,,0,0,0,,It could be a bunch of them, like all the registers.
Dialogue: 0,0:25:42.67,0:25:43.98,EN,,0,0,0,,But I could cleverly arrange it
Dialogue: 0,0:25:44.13,0:25:46.30,EN,,0,0,0,,so all the registers, all the things that are in old registers
Dialogue: 0,0:25:46.30,0:25:47.77,EN,,0,0,0,,are also at the right moment
Dialogue: 0,0:25:48.28,0:25:50.46,EN,,0,0,0,,put into this root structure,
Dialogue: 0,0:25:50.46,0:25:51.85,EN,,0,0,0,,and then we've got one pointer to it.
Dialogue: 0,0:25:51.85,0:25:52.67,EN,,0,0,0,,I don't really care.
Dialogue: 0,0:25:54.57,0:25:55.63,EN,,0,0,0,,So the idea is
Dialogue: 0,0:25:55.64,0:25:56.65,EN,,0,0,0,,we're going to cons up stuff
Dialogue: 0,0:25:56.67,0:25:58.01,EN,,0,0,0,,until our free list is empty.
Dialogue: 0,0:25:58.72,0:25:59.67,EN,,0,0,0,,We've run out of things.
Dialogue: 0,0:26:00.95,0:26:04.47,EN,,0,0,0,,Now we're going to do this process of proving the theorem
Dialogue: 0,0:26:04.47,0:26:05.90,EN,,0,0,0,,that a certain percentage of the memory
Dialogue: 0,0:26:05.95,0:26:06.90,EN,,0,0,0,,is got crap in it.
Dialogue: 0,0:26:07.85,0:26:09.15,EN,,0,0,0,,And then we're going to recycle that
Dialogue: 0,0:26:09.78,0:26:10.87,EN,,0,0,0,,to grow new trees,
Dialogue: 0,0:26:12.19,0:26:14.57,EN,,0,0,0,,a standard use of such garbage.
Dialogue: 0,0:26:17.09,0:26:18.64,EN,,0,0,0,,So in any case, what do we have here?
Dialogue: 0,0:26:18.84,0:26:20.78,EN,,0,0,0,,Well we have some data structure
Dialogue: 0,0:26:20.89,0:26:24.27,EN,,0,0,0,,which starts out over here in p5.
Dialogue: 0,0:26:25.15,0:26:26.75,EN,,0,0,0,,Sorry, and it will start at one
Dialogue: 0,0:26:27.27,0:26:28.51,EN,,0,0,0,,And in fact
Dialogue: 0,0:26:28.89,0:26:32.20,EN,,0,0,0,,it has a car in p5,
Dialogue: 0,0:26:32.27,0:26:33.58,EN,,0,0,0,,and its cdr is in two.
Dialogue: 0,0:26:33.98,0:26:35.64,EN,,0,0,0,,And all the marks start out at zero.
Dialogue: 0,0:26:36.70,0:26:39.00,EN,,0,0,0,,Well let's start marking, just to play this game.
Dialogue: 0,0:26:39.92,0:26:40.52,EN,,0,0,0,,OK.
Dialogue: 0,0:26:42.54,0:26:44.27,EN,,0,0,0,,So for example,
Dialogue: 0,0:26:44.47,0:26:46.95,EN,,0,0,0,,since I can access one from the root
Dialogue: 0,0:26:46.95,0:26:47.82,EN,,0,0,0,,I will mark that.
Dialogue: 0,0:26:48.39,0:26:49.17,EN,,0,0,0,,Let me mark it.
Dialogue: 0,0:26:50.96,0:26:51.45,EN,,0,0,0,,Bang.
Dialogue: 0,0:26:52.22,0:26:52.94,EN,,0,0,0,,That's marked.
Dialogue: 0,0:26:54.41,0:26:57.51,EN,,0,0,0,,OK. Now since I have a five here
Dialogue: 0,0:26:57.64,0:26:58.64,EN,,0,0,0,,I can go to five
Dialogue: 0,0:26:59.02,0:27:00.72,EN,,0,0,0,,and see, well I'll mark that.
Dialogue: 0,0:27:01.45,0:27:01.76,EN,,0,0,0,,Bang.
Dialogue: 0,0:27:01.76,0:27:02.60,EN,,0,0,0,,That's useful stuff.
Dialogue: 0,0:27:02.90,0:27:05.10,EN,,0,0,0,,But five references as a number in its car,
Dialogue: 0,0:27:05.27,0:27:06.65,EN,,0,0,0,,I'm not interested in marking numbers
Dialogue: 0,0:27:06.91,0:27:08.17,EN,,0,0,0,,but its cdr is seven.
Dialogue: 0,0:27:08.70,0:27:09.75,EN,,0,0,0,,So I can mark that.
Dialogue: 0,0:27:10.45,0:27:10.81,EN,,0,0,0,,Bang.
Dialogue: 0,0:27:11.80,0:27:13.40,EN,,0,0,0,,OK? Seven is the empty list,
Dialogue: 0,0:27:13.67,0:27:15.10,EN,,0,0,0,,the only thing that references,
Dialogue: 0,0:27:15.59,0:27:17.12,EN,,0,0,0,,and it's got a number in its car.
Dialogue: 0,0:27:17.12,0:27:17.85,EN,,0,0,0,,Not interesting.
Dialogue: 0,0:27:19.49,0:27:20.50,EN,,0,0,0,,Well now let's go back here.
Dialogue: 0,0:27:20.50,0:27:21.65,EN,,0,0,0,,I forgot about something.
Dialogue: 0,0:27:21.65,0:27:22.17,EN,,0,0,0,,Two.
Dialogue: 0,0:27:22.84,0:27:24.85,EN,,0,0,0,,See in other words, if I'm looking at cell one,
Dialogue: 0,0:27:25.42,0:27:29.45,EN,,0,0,0,,cell one contains a two right over here.
Dialogue: 0,0:27:30.37,0:27:31.30,EN,,0,0,0,,A reference to two.
Dialogue: 0,0:27:32.01,0:27:34.97,EN,,0,0,0,,That means I should go mark two.
Dialogue: 0,0:27:35.70,0:27:36.27,EN,,0,0,0,,Bang.
Dialogue: 0,0:27:37.14,0:27:38.89,EN,,0,0,0,,Two contains a reference to four.
Dialogue: 0,0:27:39.13,0:27:40.27,EN,,0,0,0,,It's got a number in its car,
Dialogue: 0,0:27:40.27,0:27:41.20,EN,,0,0,0,,I'm not interested in that
Dialogue: 0,0:27:41.47,0:27:42.60,EN,,0,0,0,,so I'm going to go mark that.
Dialogue: 0,0:27:43.78,0:27:46.10,EN,,0,0,0,,Four refers to seven through its car,
Dialogue: 0,0:27:46.75,0:27:48.17,EN,,0,0,0,,and is empty in its cdr,
Dialogue: 0,0:27:48.47,0:27:49.57,EN,,0,0,0,,but I've already marked that one
Dialogue: 0,0:27:49.57,0:27:50.75,EN,,0,0,0,,so I don't have to mark it again.
Dialogue: 0,0:27:51.40,0:27:53.05,EN,,0,0,0,,This is all the accessible structure
Dialogue: 0,0:27:53.07,0:27:53.87,EN,,0,0,0,,from that place.
Dialogue: 0,0:27:55.00,0:27:56.57,EN,,0,0,0,,Simple recursive mark algorithm.
Dialogue: 0,0:27:58.71,0:28:01.79,EN,,0,0,0,,Now there are some unhappinesses about that algorithm,
Dialogue: 0,0:28:01.90,0:28:04.02,EN,,0,0,0,,and we can worry about that a second.
Dialogue: 0,0:28:04.92,0:28:06.16,EN,,0,0,0,,But basically you'll see
Dialogue: 0,0:28:06.19,0:28:07.85,EN,,0,0,0,,that all the things that have not been marked
Dialogue: 0,0:28:09.62,0:28:11.50,EN,,0,0,0,,are places that are free,
Dialogue: 0,0:28:11.50,0:28:12.41,EN,,0,0,0,,and I could recycle.
Dialogue: 0,0:28:14.25,0:28:15.75,EN,,0,0,0,,So the next stage after that is going to be
Dialogue: 0,0:28:15.75,0:28:17.05,EN,,0,0,0,,to scan through all of my memory,
Dialogue: 0,0:28:17.94,0:28:20.35,EN,,0,0,0,,looking for things that are not marked.
Dialogue: 0,0:28:21.18,0:28:22.45,EN,,0,0,0,,Every time I come across a marked thing
Dialogue: 0,0:28:22.45,0:28:23.22,EN,,0,0,0,,I unmark it,
Dialogue: 0,0:28:23.22,0:28:24.86,EN,,0,0,0,,and every time I come across an unmarked thing
Dialogue: 0,0:28:25.07,0:28:27.82,EN,,0,0,0,,I'm going to link it together in my free list.
Dialogue: 0,0:28:28.77,0:28:30.30,EN,,0,0,0,,Classic, very simple algorithm.
Dialogue: 0,0:28:32.12,0:28:33.10,EN,,0,0,0,,So let's see.
Dialogue: 0,0:28:33.84,0:28:34.77,EN,,0,0,0,,Is that very simple?
Dialogue: 0,0:28:34.77,0:28:35.42,EN,,0,0,0,,Yes it is.
Dialogue: 0,0:28:35.57,0:28:37.79,EN,,0,0,0,,I'm not going to go through the code in any detail,
Dialogue: 0,0:28:38.00,0:28:39.65,EN,,0,0,0,,but I just want to show you about how long it is.
Dialogue: 0,0:28:40.09,0:28:41.10,EN,,0,0,0,,Let's look at the mark phase.
Dialogue: 0,0:28:41.72,0:28:43.98,EN,,0,0,0,,Here's the first part of the mark phase.
Dialogue: 0,0:28:45.06,0:28:46.00,EN,,0,0,0,,We pick up the root.
Dialogue: 0,0:28:46.32,0:28:47.52,EN,,0,0,0,,We're going to do some
Dialogue: 0,0:28:47.67,0:28:51.05,EN,,0,0,0,,We're going to use that as a recursive procedure call.
Dialogue: 0,0:28:52.38,0:28:54.47,EN,,0,0,0,,We're going to sweep from there,
Dialogue: 0,0:28:54.77,0:28:56.95,EN,,0,0,0,,after when we're done with marking.
Dialogue: 0,0:28:57.38,0:28:59.79,EN,,0,0,0,,And then we're going to do a little couple of instructions
Dialogue: 0,0:28:59.80,0:29:01.36,EN,,0,0,0,,that do this checking out on the marks
Dialogue: 0,0:29:01.39,0:29:03.07,EN,,0,0,0,,and changing the marks and things like that,
Dialogue: 0,0:29:03.07,0:29:04.90,EN,,0,0,0,,according to the algorithm I've just shown you.
Dialogue: 0,0:29:05.23,0:29:06.47,EN,,0,0,0,,OK? It comes out here.
Dialogue: 0,0:29:06.47,0:29:07.65,EN,,0,0,0,,You have to mark the cars of things
Dialogue: 0,0:29:07.87,0:29:10.21,EN,,0,0,0,,and you also have to be able to mark the cdrs of things.
Dialogue: 0,0:29:10.66,0:29:12.10,EN,,0,0,0,,That's the entire mark phase.
Dialogue: 0,0:29:14.37,0:29:16.16,EN,,0,0,0,,I'll just tell you a little story about this.
Dialogue: 0,0:29:16.59,0:29:19.37,EN,,0,0,0,,The old DEC PDP-6 computer,
Dialogue: 0,0:29:20.93,0:29:22.09,EN,,0,0,0,,this was the way that
Dialogue: 0,0:29:22.35,0:29:24.85,EN,,0,0,0,,the mark-sweep garbage collection, as it was, was written.
Dialogue: 0,0:29:26.91,0:29:28.40,EN,,0,0,0,,The program was so small
Dialogue: 0,0:29:29.25,0:29:31.60,EN,,0,0,0,,that with the data that it needed,
Dialogue: 0,0:29:32.20,0:29:34.87,EN,,0,0,0,,with the registers that it needed to manipulate the memory,
Dialogue: 0,0:29:36.16,0:29:38.14,EN,,0,0,0,,it fit into the fast registers of the machine,
Dialogue: 0,0:29:38.16,0:29:38.97,EN,,0,0,0,,which were 16.
Dialogue: 0,0:29:39.28,0:29:39.80,EN,,0,0,0,,The whole program.
Dialogue: 0,0:29:40.01,0:29:42.01,EN,,0,0,0,,And you could execute instructions in the fast registers.
Dialogue: 0,0:29:43.17,0:29:44.83,EN,,0,0,0,,So it's an extremely small program,
Dialogue: 0,0:29:45.85,0:29:46.88,EN,,0,0,0,,and it could run very fast.
Dialogue: 0,0:29:48.87,0:29:51.30,EN,,0,0,0,,Now unfortunately, of course,
Dialogue: 0,0:29:51.61,0:29:54.02,EN,,0,0,0,,this program, because the fact that it's recursive
Dialogue: 0,0:29:54.80,0:29:57.55,EN,,0,0,0,,in the way that you do something first
Dialogue: 0,0:29:57.55,0:29:58.99,EN,,0,0,0,,and then you do something after that,
Dialogue: 0,0:29:59.21,0:30:00.88,EN,,0,0,0,,you have to work on the cars and then the cdrs,
Dialogue: 0,0:30:01.15,0:30:02.75,EN,,0,0,0,,it requires auxiliary memory.
Dialogue: 0,0:30:03.41,0:30:05.23,EN,,0,0,0,,So Lisp systems--
Dialogue: 0,0:30:05.44,0:30:07.42,EN,,0,0,0,,those requires a stack for marking.
Dialogue: 0,0:30:08.26,0:30:11.05,EN,,0,0,0,,Lisp systems that are built this way
Dialogue: 0,0:30:11.57,0:30:14.16,EN,,0,0,0,,have a limit to the depth of recursion you can have
Dialogue: 0,0:30:14.42,0:30:17.37,EN,,0,0,0,,in data structures in either the car or the cdr,
Dialogue: 0,0:30:17.81,0:30:19.35,EN,,0,0,0,,and that doesn't work very nicely.
Dialogue: 0,0:30:19.93,0:30:20.60,EN,,0,0,0,,On the other hand,
Dialogue: 0,0:30:20.64,0:30:22.12,EN,,0,0,0,,you never notice it if it's big enough.
Dialogue: 0,0:30:23.18,0:30:25.13,EN,,0,0,0,,And that's certainly been
Dialogue: 0,0:30:25.55,0:30:28.17,EN,,0,0,0,,the case for most Maclisp, for example,
Dialogue: 0,0:30:28.69,0:30:29.88,EN,,0,0,0,,which ran Macsyma
Dialogue: 0,0:30:29.96,0:30:31.10,EN,,0,0,0,,where you could deal with expressions
Dialogue: 0,0:30:31.10,0:30:32.72,EN,,0,0,0,,of thousands of elements long.
Dialogue: 0,0:30:33.56,0:30:36.02,EN,,0,0,0,,These are algebraic expressions with thousand of terms.
Dialogue: 0,0:30:36.82,0:30:38.10,EN,,0,0,0,,And there's no problem with that.
Dialogue: 0,0:30:39.49,0:30:40.82,EN,,0,0,0,,Such, the garbage collector does work.
Dialogue: 0,0:30:42.19,0:30:42.92,EN,,0,0,0,,On the other hand,
Dialogue: 0,0:30:42.92,0:30:45.37,EN,,0,0,0,,there's a very clever modification to this algorithm,
Dialogue: 0,0:30:45.37,0:30:46.47,EN,,0,0,0,,which I will not describe,
Dialogue: 0,0:30:46.80,0:30:48.22,EN,,0,0,0,,by Peter Deutsch and Schorr and Waite--
Dialogue: 0,0:30:48.64,0:30:51.82,EN,,0,0,0,,and Schorr and Waite, Herb Schorr from IBM
Dialogue: 0,0:30:51.87,0:30:53.52,EN,,0,0,0,,and Waite who I don't know.
Dialogue: 0,0:30:54.01,0:30:56.51,EN,,0,0,0,,Whrere... That algorithm
Dialogue: 0,0:30:56.67,0:30:57.79,EN,,0,0,0,,allows you build
Dialogue: 0,0:30:57.84,0:30:59.55,EN,,0,0,0,,you do can do this without auxiliary memory,
Dialogue: 0,0:31:00.50,0:31:02.80,EN,,0,0,0,,by remembering as you walk the data structures
Dialogue: 0,0:31:02.97,0:31:05.52,EN,,0,0,0,,where you came from by reversing the pointers as you go down
Dialogue: 0,0:31:05.52,0:31:07.52,EN,,0,0,0,,and crawling up the reverse pointers as you go up.
Dialogue: 0,0:31:07.79,0:31:08.99,EN,,0,0,0,,It's a rather tricky algorithm.
Dialogue: 0,0:31:09.13,0:31:10.24,EN,,0,0,0,,The first time you write it--
Dialogue: 0,0:31:10.25,0:31:11.71,EN,,0,0,0,,or in fact, the first three times you write it it
Dialogue: 0,0:31:11.71,0:31:12.72,EN,,0,0,0,,it has a terrible bug in it.
Dialogue: 0,0:31:14.35,0:31:16.72,EN,,0,0,0,,And it's also about, it's quite rather slow,
Dialogue: 0,0:31:16.72,0:31:17.67,EN,,0,0,0,,because it's complicated.
Dialogue: 0,0:31:18.11,0:31:20.30,EN,,0,0,0,,It takes about six times as many memory references
Dialogue: 0,0:31:20.85,0:31:23.22,EN,,0,0,0,,to do the sorts of things that we're talking about.
Dialogue: 0,0:31:24.58,0:31:27.07,EN,,0,0,0,,Well now once I've done this marking phase,
Dialogue: 0,0:31:27.50,0:31:30.12,EN,,0,0,0,,and I get into a position where things look like this,
Dialogue: 0,0:31:30.17,0:31:31.26,EN,,0,0,0,,let's look-- yes.
Dialogue: 0,0:31:31.51,0:31:34.03,EN,,0,0,0,,Here we have the mark done,
Dialogue: 0,0:31:34.08,0:31:35.00,EN,,0,0,0,,just as I did it.
Dialogue: 0,0:31:35.59,0:31:37.33,EN,,0,0,0,,Now we have to perform the sweep phase.
Dialogue: 0,0:31:37.60,0:31:39.32,EN,,0,0,0,,And I described to you what this sweep is like.
Dialogue: 0,0:31:39.82,0:31:42.34,EN,,0,0,0,,I'm going to walk down from one end of memory or the other,
Dialogue: 0,0:31:42.34,0:31:43.34,EN,,0,0,0,,I don't care where,
Dialogue: 0,0:31:43.62,0:31:46.17,EN,,0,0,0,,scanning every cell that's in the memory.
Dialogue: 0,0:31:47.17,0:31:48.67,EN,,0,0,0,,And as I scan these cells,
Dialogue: 0,0:31:49.20,0:31:50.97,EN,,0,0,0,,I'm going to link them together,
Dialogue: 0,0:31:50.99,0:31:52.84,EN,,0,0,0,,if they are free, into the free list.
Dialogue: 0,0:31:53.15,0:31:54.05,EN,,0,0,0,,And if they're not free,
Dialogue: 0,0:31:54.05,0:31:56.07,EN,,0,0,0,,I'm going to unmark them so the marks become zero.
Dialogue: 0,0:31:57.50,0:31:58.57,EN,,0,0,0,,And in fact what I get--
Dialogue: 0,0:31:58.70,0:32:00.46,EN,,0,0,0,,well the program is not very complicated.
Dialogue: 0,0:32:00.46,0:32:02.22,EN,,0,0,0,,It looks sort of like this-- it's a little longer.
Dialogue: 0,0:32:02.78,0:32:04.17,EN,,0,0,0,,Here's the first piece of it.
Dialogue: 0,0:32:04.82,0:32:06.71,EN,,0,0,0,,This one's coming down from the top of memory.
Dialogue: 0,0:32:06.71,0:32:09.58,EN,,0,0,0,,I don't want you to try to understand this at this point.
Dialogue: 0,0:32:09.58,0:32:10.55,EN,,0,0,0,,It's rather simple.
Dialogue: 0,0:32:11.03,0:32:12.52,EN,,0,0,0,,It's a very simple algorithm,
Dialogue: 0,0:32:13.07,0:32:15.97,EN,,0,0,0,,but there's pieces of it that just sort of look like this.
Dialogue: 0,0:32:15.97,0:32:17.37,EN,,0,0,0,,They're all sort of obvious.
Dialogue: 0,0:32:18.60,0:32:20.08,EN,,0,0,0,,And after we've done the sweep,
Dialogue: 0,0:32:20.30,0:32:21.77,EN,,0,0,0,,we get an answer that looks like that.
Dialogue: 0,0:32:25.33,0:32:26.54,EN,,0,0,0,,Now there are some disadvantages
Dialogue: 0,0:32:26.56,0:32:28.20,EN,,0,0,0,,with mark-sweep algorithms of this sort.
Dialogue: 0,0:32:29.59,0:32:30.35,EN,,0,0,0,,Serious ones.
Dialogue: 0,0:32:31.45,0:32:33.20,EN,,0,0,0,,One important disadvantage is
Dialogue: 0,0:32:33.20,0:32:34.97,EN,,0,0,0,,that your memories get larger and larger.
Dialogue: 0,0:32:36.82,0:32:38.87,EN,,0,0,0,,As you say, address spaces get larger and larger,
Dialogue: 0,0:32:38.87,0:32:40.80,EN,,0,0,0,,you're willing to represent more and more stuff,
Dialogue: 0,0:32:41.37,0:32:44.52,EN,,0,0,0,,then it gets very costly to scan all of memory.
Dialogue: 0,0:32:46.36,0:32:47.39,EN,,0,0,0,,What you'd really like to do
Dialogue: 0,0:32:47.40,0:32:48.68,EN,,0,0,0,,is only scan useful stuff.
Dialogue: 0,0:32:50.49,0:32:51.55,EN,,0,0,0,,It would even be better
Dialogue: 0,0:32:52.07,0:32:53.90,EN,,0,0,0,,if you realized that some stuff
Dialogue: 0,0:32:54.48,0:32:57.72,EN,,0,0,0,,was known to be good and useful,
Dialogue: 0,0:32:58.28,0:33:00.37,EN,,0,0,0,,and you don't have to look at it more than once or twice.
Dialogue: 0,0:33:00.37,0:33:01.20,EN,,0,0,0,,Or very rarely.
Dialogue: 0,0:33:01.55,0:33:04.32,EN,,0,0,0,,Whereas other stuff that you're not so sure about,
Dialogue: 0,0:33:05.00,0:33:06.22,EN,,0,0,0,,you can look at more detail
Dialogue: 0,0:33:07.10,0:33:08.75,EN,,0,0,0,,every time you want to do this,
Dialogue: 0,0:33:09.93,0:33:10.85,EN,,0,0,0,,want to garbage collect.
Dialogue: 0,0:33:11.91,0:33:13.74,EN,,0,0,0,,Well there are algorithms
Dialogue: 0,0:33:13.76,0:33:15.10,EN,,0,0,0,,that are organized in this way.
Dialogue: 0,0:33:15.66,0:33:18.16,EN,,0,0,0,,Let me tell you about a famous old algorithm
Dialogue: 0,0:33:18.28,0:33:19.47,EN,,0,0,0,,which allows you only look at
Dialogue: 0,0:33:19.50,0:33:21.37,EN,,0,0,0,,the part of memory which is known to be useful.
Dialogue: 0,0:33:23.12,0:33:23.85,EN,,0,0,0,,And which happens to be
Dialogue: 0,0:33:23.87,0:33:25.29,EN,,0,0,0,,the fastest known garbage collector algorithm.
Dialogue: 0,0:33:26.31,0:33:29.45,EN,,0,0,0,,This is the Minsky-Fenichel-Yochelson garbage collector algorithm.
Dialogue: 0,0:33:30.40,0:33:33.18,EN,,0,0,0,,It was invented by Minsky
Dialogue: 0,0:33:33.20,0:33:36.06,EN,,0,0,0,,in 1961 or '60 or something,
Dialogue: 0,0:33:36.52,0:33:40.48,EN,,0,0,0,,for the RLE PDP-1 Lisp,
Dialogue: 0,0:33:40.51,0:33:43.44,EN,,0,0,0,,which had 4,096 words of list memory,
Dialogue: 0,0:33:45.79,0:33:46.76,EN,,0,0,0,,and a drum.
Dialogue: 0,0:33:48.48,0:33:49.39,EN,,0,0,0,,And the whole idea
Dialogue: 0,0:33:50.03,0:33:51.87,EN,,0,0,0,,was to garbage collect this terrible memory.
Dialogue: 0,0:33:53.05,0:33:54.35,EN,,0,0,0,,What Minsky realized
Dialogue: 0,0:33:54.38,0:33:55.62,EN,,0,0,0,,was the easiest way to do this
Dialogue: 0,0:33:56.20,0:33:58.47,EN,,0,0,0,,is to scan the memory in the same sense,
Dialogue: 0,0:33:58.47,0:34:00.60,EN,,0,0,0,,walking the good structure,
Dialogue: 0,0:34:01.57,0:34:03.52,EN,,0,0,0,,copying it out into the drum,
Dialogue: 0,0:34:04.70,0:34:05.47,EN,,0,0,0,,compacted.
Dialogue: 0,0:34:06.35,0:34:08.86,EN,,0,0,0,,And then when we were done copying it all out,
Dialogue: 0,0:34:09.12,0:34:10.90,EN,,0,0,0,,then you swap that back into your memory.
Dialogue: 0,0:34:12.30,0:34:13.68,EN,,0,0,0,,Now whether or you not use a drum,
Dialogue: 0,0:34:13.72,0:34:14.71,EN,,0,0,0,,or another piece of memory,
Dialogue: 0,0:34:14.71,0:34:16.42,EN,,0,0,0,,or something like that isn't important.
Dialogue: 0,0:34:17.03,0:34:17.42,EN,,0,0,0,,In fact,
Dialogue: 0,0:34:17.44,0:34:19.60,EN,,0,0,0,,I don't think people use drums anymore for anything.
Dialogue: 0,0:34:20.35,0:34:23.77,EN,,0,0,0,,But this algorithm basically
Dialogue: 0,0:34:24.03,0:34:25.42,EN,,0,0,0,,depends upon having
Dialogue: 0,0:34:25.42,0:34:27.42,EN,,0,0,0,,about twice as much address space
Dialogue: 0,0:34:27.48,0:34:28.57,EN,,0,0,0,,you're actually using.
Dialogue: 0,0:34:30.27,0:34:32.96,EN,,0,0,0,,And so what you have is some, initially,
Dialogue: 0,0:34:33.12,0:34:36.60,EN,,0,0,0,,some mixture of useful data and garbage.
Dialogue: 0,0:34:37.11,0:34:38.97,EN,,0,0,0,,So this is called fromspace.
Dialogue: 0,0:34:45.17,0:34:47.05,EN,,0,0,0,,And this is a mixture of crud.
Dialogue: 0,0:34:47.87,0:34:49.79,EN,,0,0,0,,Some of it's important and some of it isn't.
Dialogue: 0,0:34:52.00,0:34:53.85,EN,,0,0,0,,Now there's another place
Dialogue: 0,0:34:54.17,0:34:55.61,EN,,0,0,0,,which is hopefully big enough,
Dialogue: 0,0:34:55.77,0:34:57.00,EN,,0,0,0,,if we recall, tospace,
Dialogue: 0,0:34:57.12,0:34:58.24,EN,,0,0,0,,which is where we're copying to.
Dialogue: 0,0:35:01.59,0:35:02.60,EN,,0,0,0,,And what happens is--
Dialogue: 0,0:35:02.60,0:35:04.06,EN,,0,0,0,,and I'm not going to go through this detail.
Dialogue: 0,0:35:04.16,0:35:07.07,EN,,0,0,0,,It's in our book quite explicitly.
Dialogue: 0,0:35:07.59,0:35:10.40,EN,,0,0,0,,There's a root point where you start from.
Dialogue: 0,0:35:11.03,0:35:14.30,EN,,0,0,0,,And the idea is that you start with the root.
Dialogue: 0,0:35:14.60,0:35:16.42,EN,,0,0,0,,You copy the first thing you see,
Dialogue: 0,0:35:17.83,0:35:19.37,EN,,0,0,0,,the first thing that the root points at,
Dialogue: 0,0:35:19.75,0:35:21.31,EN,,0,0,0,,to the beginning of tospace.
Dialogue: 0,0:35:22.81,0:35:24.12,EN,,0,0,0,,The first thing is a pair
Dialogue: 0,0:35:24.16,0:35:25.60,EN,,0,0,0,,or something like, a data structure.
Dialogue: 0,0:35:27.56,0:35:30.19,EN,,0,0,0,,You then also leave behind
Dialogue: 0,0:35:30.38,0:35:31.56,EN,,0,0,0,,a broken heart saying,
Dialogue: 0,0:35:31.77,0:35:35.74,EN,,0,0,0,,I moved this object from here to here,
Dialogue: 0,0:35:35.74,0:35:37.05,EN,,0,0,0,,giving the place where it moved to.
Dialogue: 0,0:35:37.80,0:35:39.65,EN,,0,0,0,,This is called a broken heart because
Dialogue: 0,0:35:39.65,0:35:40.78,EN,,0,0,0,,a friend of mine who implemented
Dialogue: 0,0:35:40.78,0:35:43.39,EN,,0,0,0,,one of these in 1966
Dialogue: 0,0:35:43.82,0:35:45.26,EN,,0,0,0,,was a very romantic character
Dialogue: 0,0:35:45.26,0:35:46.76,EN,,0,0,0,,and called it a broken heart.
Dialogue: 0,0:35:49.58,0:35:50.54,EN,,0,0,0,,But in any case,
Dialogue: 0,0:35:51.15,0:35:52.72,EN,,0,0,0,,the next thing you do
Dialogue: 0,0:35:52.94,0:35:55.00,EN,,0,0,0,,is now you have a new free pointer which is here,
Dialogue: 0,0:35:55.17,0:35:56.38,EN,,0,0,0,,and you start scanning.
Dialogue: 0,0:35:56.88,0:35:59.68,EN,,0,0,0,,You scan this data structure you just copied.
Dialogue: 0,0:36:00.55,0:36:02.19,EN,,0,0,0,,And every time you encounter a pointer in it,
Dialogue: 0,0:36:02.19,0:36:03.92,EN,,0,0,0,,you treat it as if it was the root pointer here.
Dialogue: 0,0:36:04.00,0:36:04.59,EN,,0,0,0,,Oh, I'm sorry.
Dialogue: 0,0:36:04.60,0:36:05.69,EN,,0,0,0,,The other thing you do
Dialogue: 0,0:36:05.71,0:36:07.08,EN,,0,0,0,,is you now move the root pointer to there.
Dialogue: 0,0:36:09.22,0:36:10.17,EN,,0,0,0,,So now you scan this,
Dialogue: 0,0:36:10.17,0:36:10.99,EN,,0,0,0,,and everything you see
Dialogue: 0,0:36:11.00,0:36:12.41,EN,,0,0,0,,you treat as it were the root pointer.
Dialogue: 0,0:36:14.11,0:36:15.45,EN,,0,0,0,,So if you see something,
Dialogue: 0,0:36:15.45,0:36:17.40,EN,,0,0,0,,well it points up into there somewhere.
Dialogue: 0,0:36:18.51,0:36:19.92,EN,,0,0,0,,Is it pointing at a thing
Dialogue: 0,0:36:19.93,0:36:20.99,EN,,0,0,0,,which you've not copied yet?
Dialogue: 0,0:36:21.78,0:36:22.87,EN,,0,0,0,,Is there a broken heart there?
Dialogue: 0,0:36:23.88,0:36:24.84,EN,,0,0,0,,If there's a broken heart there
Dialogue: 0,0:36:24.84,0:36:26.11,EN,,0,0,0,,and it's something you have copied,
Dialogue: 0,0:36:26.20,0:36:27.34,EN,,0,0,0,,you've just replaced this pointer
Dialogue: 0,0:36:27.36,0:36:28.75,EN,,0,0,0,,with the thing a broken heart points at.
Dialogue: 0,0:36:29.82,0:36:32.03,EN,,0,0,0,,If this thing has not been copied,
Dialogue: 0,0:36:32.12,0:36:34.08,EN,,0,0,0,,you copy it to the next place over here.
Dialogue: 0,0:36:34.43,0:36:35.95,EN,,0,0,0,,Move your free pointer over here,
Dialogue: 0,0:36:37.05,0:36:40.60,EN,,0,0,0,,and then leave a broken heart behind
Dialogue: 0,0:36:41.05,0:36:41.80,EN,,0,0,0,,and scan.
Dialogue: 0,0:36:43.67,0:36:46.40,EN,,0,0,0,,And eventually when the scant pointer hits the free pointer,
Dialogue: 0,0:36:46.82,0:36:48.52,EN,,0,0,0,,everything in memory has been copied.
Dialogue: 0,0:36:50.14,0:36:51.04,EN,,0,0,0,,And then there's a whole bunch
Dialogue: 0,0:36:51.05,0:36:51.95,EN,,0,0,0,,of empty space up here,
Dialogue: 0,0:36:51.96,0:36:53.28,EN,,0,0,0,,which you could either make into a free list,
Dialogue: 0,0:36:53.31,0:36:54.47,EN,,0,0,0,,if that's what you want to do.
Dialogue: 0,0:36:54.47,0:36:56.27,EN,,0,0,0,,But generally you don't in this kind of system.
Dialogue: 0,0:36:56.27,0:36:59.15,EN,,0,0,0,,In this system you sequentially allocate your memory.
Dialogue: 0,0:37:00.91,0:37:02.48,EN,,0,0,0,,That is a very, very nice algorithm,
Dialogue: 0,0:37:02.97,0:37:04.57,EN,,0,0,0,,and sort of the one we use in the
Dialogue: 0,0:37:04.67,0:37:05.97,EN,,0,0,0,,the scheme that you've been using.
Dialogue: 0,0:37:06.79,0:37:09.47,EN,,0,0,0,,And it's known to be... it's expected--
Dialogue: 0,0:37:09.47,0:37:10.86,EN,,0,0,0,,I believe no one has found
Dialogue: 0,0:37:10.89,0:37:12.12,EN,,0,0,0,,a faster algorithm than that.
Dialogue: 0,0:37:12.40,0:37:14.85,EN,,0,0,0,,There are very simple modifications to this algorithm
Dialogue: 0,0:37:14.85,0:37:16.77,EN,,0,0,0,,invented by Henry Baker
Dialogue: 0,0:37:17.17,0:37:20.31,EN,,0,0,0,,which allow one to run this algorithm in real time,
Dialogue: 0,0:37:20.31,0:37:21.92,EN,,0,0,0,,meaning you don't have to stop to garbage collect.
Dialogue: 0,0:37:22.14,0:37:24.33,EN,,0,0,0,,But you could interleave the consing
Dialogue: 0,0:37:24.36,0:37:26.17,EN,,0,0,0,,that the machine does when its running
Dialogue: 0,0:37:26.32,0:37:28.40,EN,,0,0,0,,with steps of the garbage collection process,
Dialogue: 0,0:37:28.85,0:37:31.20,EN,,0,0,0,,so that the thing, the garbage collector's distributed
Dialogue: 0,0:37:31.20,0:37:32.19,EN,,0,0,0,,and the machine doesn't have to stop,
Dialogue: 0,0:37:32.41,0:37:33.47,EN,,0,0,0,,and garbage collecting can start.
Dialogue: 0,0:37:34.64,0:37:37.87,EN,,0,0,0,,Of course in the case of machines with virtual memory
Dialogue: 0,0:37:38.90,0:37:41.20,EN,,0,0,0,,where a lot of it is in inaccessible places,
Dialogue: 0,0:37:41.50,0:37:43.60,EN,,0,0,0,,this becomes a very expensive process.
Dialogue: 0,0:37:44.28,0:37:46.43,EN,,0,0,0,,And there have been numerous
Dialogue: 0,0:37:47.16,0:37:48.65,EN,,0,0,0,,attempts to make this much better.
Dialogue: 0,0:37:49.19,0:37:51.15,EN,,0,0,0,,There is a nice paper,
Dialogue: 0,0:37:51.16,0:37:52.41,EN,,0,0,0,,for those of you who are interested,
Dialogue: 0,0:37:52.64,0:37:54.27,EN,,0,0,0,,by Moon and other people
Dialogue: 0,0:37:54.65,0:37:56.89,EN,,0,0,0,,which describes a modification to
Dialogue: 0,0:37:56.92,0:37:59.44,EN,,0,0,0,,the incremental Minsky-Fenichel-Yochelson algorithm,
Dialogue: 0,0:37:59.51,0:38:01.20,EN,,0,0,0,,and modification the Baker algorithm
Dialogue: 0,0:38:01.42,0:38:06.54,EN,,0,0,0,,which is more efficient for virtual memory systems.
Dialogue: 0,0:38:08.27,0:38:12.32,EN,,0,0,0,,Well I think now the mystery to this is sort of gone.
Dialogue: 0,0:38:12.84,0:38:14.09,EN,,0,0,0,,And I'd like to see if there are any questions.
Dialogue: 0,0:38:19.78,0:38:19.95,EN,,0,0,0,,Yes.
Dialogue: 0,0:38:20.60,0:38:23.58,EN,,0,0,0,,AUDIENCE: I saw one of you run the garbage collector
Dialogue: 0,0:38:23.64,0:38:25.05,EN,,0,0,0,,on the systems upstairs,
Dialogue: 0,0:38:25.93,0:38:27.88,EN,,0,0,0,,and it seemed to me to run extremely fast.
Dialogue: 0,0:38:27.96,0:38:28.40,EN,,0,0,0,,PROFESSOR: Yes
Dialogue: 0,0:38:28.49,0:38:29.52,EN,,0,0,0,,AUDIENCE: Did the whole thing take--
Dialogue: 0,0:38:30.11,0:38:31.88,EN,,0,0,0,,does it sweep through all of memory?
Dialogue: 0,0:38:31.88,0:38:32.22,EN,,0,0,0,,PROFESSOR: No.
Dialogue: 0,0:38:32.25,0:38:34.11,EN,,0,0,0,,It swept through exactly what was needed
Dialogue: 0,0:38:34.33,0:38:35.63,EN,,0,0,0,,to copy the useful structure.
Dialogue: 0,0:38:37.32,0:38:38.36,EN,,0,0,0,,It's a copying collector.
Dialogue: 0,0:38:38.44,0:38:38.91,EN,,0,0,0,,AUDIENCE: OK.
Dialogue: 0,0:38:39.30,0:38:40.88,EN,,0,0,0,,PROFESSOR: And it's rather... it is very fast.
Dialogue: 0,0:38:41.85,0:38:45.88,EN,,0,0,0,,On the whole, I suppose to copy in a Bobcat
Dialogue: 0,0:38:47.12,0:38:51.56,EN,,0,0,0,,to copy, I think, a three megabyte thing or something
Dialogue: 0,0:38:52.43,0:38:53.24,EN,,0,0,0,,is less than a second,
Dialogue: 0,0:38:55.00,0:38:55.69,EN,,0,0,0,,real time
Dialogue: 0,0:38:56.54,0:38:58.46,EN,,0,0,0,,Really, these are very small programs.
Dialogue: 0,0:38:58.62,0:39:01.50,EN,,0,0,0,,One thing you should realise is that
Dialogue: 0,0:39:02.91,0:39:04.40,EN,,0,0,0,,garbage collectors have to be small.
Dialogue: 0,0:39:05.40,0:39:07.10,EN,,0,0,0,,Not because they have to be fast,
Dialogue: 0,0:39:07.90,0:39:09.23,EN,,0,0,0,,but because no one can debug
Dialogue: 0,0:39:09.26,0:39:10.48,EN,,0,0,0,,a complicated garbage collector.
Dialogue: 0,0:39:11.34,0:39:12.91,EN,,0,0,0,,A garbage collector, if it doesn't work,
Dialogue: 0,0:39:14.04,0:39:15.93,EN,,0,0,0,,will trash your memory in such a way
Dialogue: 0,0:39:15.93,0:39:17.39,EN,,0,0,0,,that you cannot figure out what the hell happened.
Dialogue: 0,0:39:18.35,0:39:19.67,EN,,0,0,0,,You need an audit trail.
Dialogue: 0,0:39:20.66,0:39:22.01,EN,,0,0,0,,Because it rearranges everything,
Dialogue: 0,0:39:22.04,0:39:23.24,EN,,0,0,0,,and how do you know what happened there?
Dialogue: 0,0:39:23.74,0:39:26.58,EN,,0,0,0,,So this is the only kind of program that
Dialogue: 0,0:39:26.92,0:39:28.40,EN,,0,0,0,,it really, seriously matters
Dialogue: 0,0:39:28.54,0:39:29.79,EN,,0,0,0,,if you stare at it long enough
Dialogue: 0,0:39:29.82,0:39:31.07,EN,,0,0,0,,so you believe that it works.
Dialogue: 0,0:39:31.34,0:39:33.36,EN,,0,0,0,,That means and sort of prove it to yourself.
Dialogue: 0,0:39:33.92,0:39:36.11,EN,,0,0,0,,And that, that... So there's no way to debug it.
Dialogue: 0,0:39:36.94,0:39:38.96,EN,,0,0,0,,And that takes it being small enough
Dialogue: 0,0:39:38.96,0:39:39.97,EN,,0,0,0,,so you can hold it in your head.
Dialogue: 0,0:39:41.45,0:39:43.90,EN,,0,0,0,,So garbage collectors are special in this way.
Dialogue: 0,0:39:45.02,0:39:47.12,EN,,0,0,0,,So every reasonable garbage collector has gotten small,
Dialogue: 0,0:39:47.13,0:39:48.45,EN,,0,0,0,,and generally small programs are fast.
Dialogue: 0,0:39:52.05,0:39:52.43,EN,,0,0,0,,Yes.
Dialogue: 0,0:39:52.43,0:39:54.51,EN,,0,0,0,,AUDIENCE: Can you repeat the name of this technique once again?
Dialogue: 0,0:39:54.68,0:39:56.92,EN,,0,0,0,,PROFESSOR: That's the Minsky-Fenichel-Yochelson garbage collector.
Dialogue: 0,0:39:57.88,0:39:58.43,EN,,0,0,0,,AUDIENCE: You got that?
Dialogue: 0,0:39:59.00,0:40:00.78,EN,,0,0,0,,PROFESSOR: Minsky invented it in '61
Dialogue: 0,0:40:00.81,0:40:02.21,EN,,0,0,0,,for the RLE PDP-1.
Dialogue: 0,0:40:02.21,0:40:06.17,EN,,0,0,0,,A version of it was developed and elaborated
Dialogue: 0,0:40:06.45,0:40:10.27,EN,,0,0,0,,to be used in Multics Maclisp by Fenichel and Yochelson
Dialogue: 0,0:40:11.37,0:40:14.75,EN,,0,0,0,,in somewhere around 1968 or '69.
Dialogue: 0,0:40:19.57,0:40:21.36,EN,,0,0,0,,OK. Let's take a break.
Dialogue: 0,0:40:22.64,0:40:32.36,EN,,0,0,0,,[JESU, JOY OF MAN'S DESIRING]
Dialogue: 0,0:40:32.41,0:40:36.19,EN,,0,0,0,,The Structure And Interpretation of Computer Programs
Dialogue: 0,0:41:03.15,0:41:07.18,EN,,0,0,0,,By: Prof. Harold Abelson && Sussman Jay Sussman
Dialogue: 0,0:41:07.20,0:41:10.17,EN,,0,0,0,,The Structure And Interpretation of Computer Programs
Dialogue: 0,0:41:10.20,0:41:14.22,EN,,0,0,0,,Not Everything Can Be Computed
Dialogue: 0,0:41:17.31,0:41:19.67,EN,,0,0,0,,PROFESSOR: Well we've come to the end of this subject,
Dialogue: 0,0:41:20.08,0:41:23.85,EN,,0,0,0,,and we've already shown you a universal machine
Dialogue: 0,0:41:24.47,0:41:26.74,EN,,0,0,0,,which is down to evaluator.
Dialogue: 0,0:41:27.02,0:41:28.38,EN,,0,0,0,,It's down to the level of detail
Dialogue: 0,0:41:28.38,0:41:29.67,EN,,0,0,0,,you could imagine you could make one.
Dialogue: 0,0:41:30.19,0:41:33.32,EN,,0,0,0,,This is a particular implementation of Lisp,
Dialogue: 0,0:41:33.90,0:41:36.01,EN,,0,0,0,,built on one of those
Dialogue: 0,0:41:36.16,0:41:38.05,EN,,0,0,0,,scheme chips that was talked about yesterday,
Dialogue: 0,0:41:38.20,0:41:38.91,EN,,0,0,0,,sitting over here.