forked from DeathKing/Learning-SICP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlec9b_512kb.mp4.srt
4500 lines (3375 loc) · 94 KB
/
lec9b_512kb.mp4.srt
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
1
00:00:15,840 --> 00:00:20,260
PROFESSOR: Well, I hope you appreciate that we have
2
00:00:20,260 --> 00:00:24,562
inducted you into some real magic,
3
00:00:24,562 --> 00:00:29,500
the magic of building languages, really building new languages.
4
00:00:29,500 --> 00:00:31,275
What have we looked at? We've looked at
5
00:00:31,275 --> 00:00:38,925
an Escher picture language:
6
00:00:38,925 --> 00:00:42,141
this language invented by Peter Henderson.
7
00:00:42,141 --> 00:00:47,600
We looked at digital logic language.
8
00:00:53,000 --> 00:00:56,944
Let's see.We've looked at the query language.
9
00:00:59,700 --> 00:01:04,700
And the thing you should realize is, even though these were toy examples,
10
00:01:04,700 --> 00:01:08,250
they really are the kernels of really useful things.
11
00:01:08,250 --> 00:01:12,375
So, for instance, the Escher picture language was taken by
12
00:01:12,375 --> 00:01:14,450
Henry Wu, who's a student at MIT,
13
00:01:14,450 --> 00:01:20,350
and developed into a real language for laying out PC boards,
14
00:01:20,350 --> 00:01:23,244
based just on extending those structures.
15
00:01:23,244 --> 00:01:26,350
And the digital logic language, Jerry mentioned when he showed it to you,
16
00:01:26,350 --> 00:01:30,850
was really extended to be used as the basis for a simulator
17
00:01:30,850 --> 00:01:33,460
that was used to design a real computer.
18
00:01:33,460 --> 00:01:37,510
And the query language, of course, is kind of the germ of prologue.
19
00:01:37,510 --> 00:01:39,425
So we built all of these languages,
20
00:01:39,425 --> 00:01:42,300
they're all based on LISP.
21
00:01:43,630 --> 00:01:45,275
A lot of people ask
22
00:01:45,275 --> 00:01:48,606
what particular problems is LISP good for solving for?
23
00:01:48,606 --> 00:01:53,450
The answer is LISP is not good for solving any particular problems.
24
00:01:53,450 --> 00:01:56,213
What LISP is good for is constructing within it
25
00:01:56,213 --> 00:01:59,175
the right language to solve the problems you want to solve,
26
00:01:59,175 --> 00:02:01,470
and that's how you should think about it.
27
00:02:01,470 --> 00:02:04,326
So all of these languages were based on LISP.
28
00:02:04,326 --> 00:02:06,925
Now, what's LISP based on?
29
00:02:06,925 --> 00:02:09,400
Where's that come from? Well, we looked at that too.
30
00:02:09,400 --> 00:02:22,935
We looked at the meta-circular evaluator
31
00:02:22,935 --> 00:02:25,810
and said well, LISP is based on LISP.
32
00:02:25,810 --> 00:02:28,275
And when we start looking at that,
33
00:02:28,275 --> 00:02:29,950
we've got to do some real magic, right?
34
00:02:29,950 --> 00:02:31,660
So what does that mean, right?
35
00:02:31,660 --> 00:02:37,350
Why operators, and fixed points, and the idea that
36
00:02:37,350 --> 00:02:41,000
what this means is that LISP is somehow the fixed-point equation
37
00:02:41,000 --> 00:02:47,400
for this funny set of things which are defined in terms of themselves.
38
00:02:47,400 --> 00:02:49,070
Now, it's real magic.
39
00:02:49,070 --> 00:02:52,625
Well, today, for a final piece of magic,
40
00:02:52,625 --> 00:03:01,852
we're going to make all the magic go away.
41
00:03:06,430 --> 00:03:09,770
We already know how to do that.
42
00:03:09,770 --> 00:03:13,135
The idea is, we're going to take the register machine architecture
43
00:03:13,135 --> 00:03:15,500
and show how to implement LISP on terms of that.
44
00:03:15,500 --> 00:03:21,325
And, remember, the idea of the register machine is that
45
00:03:21,325 --> 00:03:24,800
there's a fixed and finite part of the machine.
46
00:03:24,800 --> 00:03:27,050
There's a finite-state controller, which does some
47
00:03:27,050 --> 00:03:30,510
particular thing with a particular amount of hardware.
48
00:03:30,510 --> 00:03:33,550
There are particular data paths, the operation the machine does
49
00:03:33,550 --> 00:03:37,725
And then, in order to implement recursion and sustain the illusion of infinity,
50
00:03:37,725 --> 00:03:42,060
there's some large amount of memory, which is the stack.
51
00:03:42,060 --> 00:03:47,025
So, if we implement LISP in terms of a register machine,
52
00:03:47,025 --> 00:03:49,850
then everything ought to become, at this point,completely concrete.
53
00:03:49,850 --> 00:03:51,650
All the magic should go away.
54
00:03:51,650 --> 00:03:55,140
And, by the end of this talk, I want you get the feeling
55
00:03:55,140 --> 00:03:59,675
that, as opposed to this very mysterious meta-circular evaluator
56
00:03:59,675 --> 00:04:02,850
that a LISP evaluator really is something that's concrete enough
57
00:04:02,850 --> 00:04:04,720
that you can hold in the palm of your hand.
58
00:04:04,720 --> 00:04:06,450
You should be able to imagine holding
59
00:04:06,450 --> 00:04:09,546
holding a LISP interpreter there.
60
00:04:09,546 --> 00:04:10,950
All right, how are we going to do this?
61
00:04:10,950 --> 00:04:13,960
We already have all the ingredients.
62
00:04:13,960 --> 00:04:17,450
See, what you learned last time from Jerry
63
00:04:17,450 --> 00:04:22,600
is how to take any particular couple of LISP procedures
64
00:04:22,600 --> 00:04:28,210
and hand-translate them into something that runs on a register machine.
65
00:04:28,210 --> 00:04:30,525
So, to implement all of LISP on a register machine,
66
00:04:30,525 --> 00:04:33,600
all we have to do is take the particular procedures
67
00:04:33,600 --> 00:04:36,050
that are the meta-circular evaluator
68
00:04:36,050 --> 00:04:38,825
and hand-translate them for a register machine.
69
00:04:38,825 --> 00:04:42,320
And that does all of LISP, right?
70
00:04:42,320 --> 00:04:45,380
So, in principle, we already know how to do this.
71
00:04:45,380 --> 00:04:51,275
And, indeed, it's going to be no different, in kind, from
72
00:04:51,275 --> 00:04:54,670
from translating, say, recursive factorial or recursive Fibonacci.
73
00:04:54,670 --> 00:04:56,840
It's just bigger and there's more of it.
74
00:04:56,840 --> 00:05:01,375
So it'd just be more details, but nothing really conceptually new.
75
00:05:01,375 --> 00:05:04,876
And also, when we've done that, and the thing is completely explicit,
76
00:05:04,876 --> 00:05:06,990
and we see how to implement LISP in terms of
77
00:05:06,990 --> 00:05:10,085
the actual sequential register operations,
78
00:05:10,085 --> 00:05:14,810
that's going to be our final most explicit model of LISP in this course.
79
00:05:14,810 --> 00:05:16,950
And, remember, that's a progression through this course.
80
00:05:16,950 --> 00:05:20,100
We started out with substitution, which is sort of like algebra.
81
00:05:20,100 --> 00:05:21,838
And then we went to the environment model,
82
00:05:21,838 --> 00:05:26,125
which talked about the actual frames and how they got linked together.
83
00:05:26,125 --> 00:05:31,080
And then we made that more concrete in the meta-circular evaluator.
84
00:05:31,080 --> 00:05:34,360
There are things the meta-circular evaluator doesn't tell us.
85
00:05:34,360 --> 00:05:36,090
You should realize that.
86
00:05:36,090 --> 00:05:40,420
For instance, it left unanswered the question of how
87
00:05:40,420 --> 00:05:45,175
a procedure, like recursive factorial here,
88
00:05:45,175 --> 00:05:47,210
somehow takes space that grows.
89
00:05:47,210 --> 00:05:51,948
On the other hand, a procedure which also looks syntactically recursive,
90
00:05:51,948 --> 00:05:56,760
called fact-iter, somehow doesn't take space.We justify ,
91
00:05:56,760 --> 00:06:00,500
We justify that it doesn't need to take space
92
00:06:00,500 --> 00:06:01,960
by showing the substitution model.
93
00:06:01,960 --> 00:06:07,275
But we didn't really say how it happens that the machine manages to do that,
94
00:06:07,275 --> 00:06:09,161
that that has to do with the details
95
00:06:09,161 --> 00:06:12,250
of how arguments are passed to procedures.
96
00:06:12,250 --> 00:06:15,846
And that's the thing we didn't see in the meta-circular evaluator precisely
97
00:06:15,846 --> 00:06:19,700
because the way arguments got passed to procedures in this LISP
98
00:06:19,700 --> 00:06:25,050
depended on the way arguments got passed to procedures in this LISP.
99
00:06:26,070 --> 00:06:30,740
But, now, that's going to become extremely explicit.
100
00:06:30,740 --> 00:06:31,230
OK.
101
00:06:31,230 --> 00:06:34,426
Well, before going on to the evaluator,
102
00:06:34,426 --> 00:06:37,600
let me just give you a sense of what a whole LISP system looks like
103
00:06:37,600 --> 00:06:39,086
so you can see the parts we're going to talk about
104
00:06:39,086 --> 00:06:43,250
and the parts we're not going to talk about.
105
00:06:43,250 --> 00:06:48,675
Let's see, over here is a happy LISP user,
106
00:06:48,675 --> 00:06:53,245
and the LISP user is talking to something called the reader.
107
00:07:00,360 --> 00:07:14,170
The reader's job in life is to take characters from the user
108
00:07:14,170 --> 00:07:17,960
and turn them into data structures in something called
109
00:07:17,960 --> 00:07:21,405
a list structure memory.
110
00:07:29,783 --> 00:07:32,653
All right, so the reader is going to take
111
00:07:32,653 --> 00:07:36,953
symbols, parentheses, and A's and B's, and 1s and 3s that you type in,
112
00:07:36,953 --> 00:07:39,150
and turn these into actual list structure:
113
00:07:39,150 --> 00:07:39,156
pairs, and pointers, and things.
114
00:07:39,156 --> 00:07:42,340
pairs, and pointers, and things.
115
00:07:42,340 --> 00:07:45,850
And so, by the time evaluator is going, there are no characters in the world.
116
00:07:45,850 --> 00:07:49,480
And, of course, in more modern list systems, there's sort of
117
00:07:49,480 --> 00:07:52,325
a big morass here that might sit between the user and the reader:
118
00:07:52,325 --> 00:07:54,775
Windows systems, and top levels,
119
00:07:54,775 --> 00:07:56,280
and mice, and all kinds of things.
120
00:07:56,280 --> 00:07:59,590
But conceptually, characters are coming in.
121
00:07:59,590 --> 00:08:05,525
All right, the reader transforms these into pointers
122
00:08:05,525 --> 00:08:08,275
pointers to stuff in this memory,
123
00:08:08,275 --> 00:08:12,445
and that's what the evaluator sees
124
00:08:15,300 --> 00:08:17,090
OK?
125
00:08:17,090 --> 00:08:17,300
The evaluator has a bunch of helpers.
126
00:08:17,300 --> 00:08:19,780
The evaluator has a bunch of helpers.
127
00:08:19,780 --> 00:08:23,080
It has all possible primitive operators you might want.
128
00:08:23,080 --> 00:08:28,400
So there's a completely separate box,
129
00:08:28,400 --> 00:08:32,225
a floating point unit,
130
00:08:32,225 --> 00:08:35,960
or all sorts of things, which do the primitive operators.
131
00:08:35,960 --> 00:08:37,548
And, if you want more special primitives,
132
00:08:37,548 --> 00:08:42,080
you build more primitive operators, but they're separate from the evaluator.
133
00:08:42,080 --> 00:08:45,025
The evaluator finally gets an answer
134
00:08:45,025 --> 00:08:50,450
and communicates that to the printer.
135
00:08:50,780 --> 00:08:52,265
And now, the printer's job in life is to take
136
00:08:52,265 --> 00:08:55,318
this list structure coming from the evaluator,
137
00:08:55,318 --> 00:08:57,614
and turn it back into characters,
138
00:09:01,700 --> 00:09:04,075
and communicate them to the user through
139
00:09:04,075 --> 00:09:05,750
whatever interface there is.
140
00:09:08,050 --> 00:09:12,670
OK. Well, today, what we're going to talk about is this evaluator.
141
00:09:12,670 --> 00:09:15,200
The primitive operators have nothing particular to do with LISP,
142
00:09:15,200 --> 00:09:19,175
they're however you like to implement primitive operations.
143
00:09:19,175 --> 00:09:22,187
The reader and printer are actually complicated,
144
00:09:22,187 --> 00:09:24,420
but we're not going to talk about them.
145
00:09:24,420 --> 00:09:27,100
They sort of have to do with details of how you might build
146
00:09:27,100 --> 00:09:29,900
build up list structure from characters.
147
00:09:29,900 --> 00:09:32,490
So that is a long story, but we're not going to talk about it,
148
00:09:32,490 --> 00:09:36,930
the list structure memory, we'll talk about next time.
149
00:09:36,930 --> 00:09:40,125
So, pretty much, except for the details of reading and printing,
150
00:09:40,125 --> 00:09:43,250
the only mystery that's going to be left after you see the evaluator
151
00:09:43,250 --> 00:09:46,295
is how you build list structure on conventional memories.
152
00:09:46,295 --> 00:09:50,580
But we'll worry about that next time too.
153
00:09:50,580 --> 00:09:51,830
OK.
154
00:09:53,350 --> 00:09:56,110
Well, let's start talking about the evaluator.
155
00:09:56,110 --> 00:09:59,775
The one that we're going to show you, of course, is not,
156
00:09:59,775 --> 00:10:01,120
I think, nothing special about it.
157
00:10:01,120 --> 00:10:04,810
It's just a particular register machine that runs LISP.
158
00:10:04,810 --> 00:10:09,890
And it has seven registers, and here are the seven registers.
159
00:10:09,890 --> 00:10:14,925
There's a register, called EXP, and its job is to
160
00:10:14,925 --> 00:10:18,370
hold the expression to be evaluated.
161
00:10:18,370 --> 00:10:21,750
And by that, I mean it's going to hold a pointer
162
00:10:21,750 --> 00:10:23,764
to someplace in list structure memory that holds
163
00:10:23,764 --> 00:10:26,550
the expression to be evaluated.
164
00:10:26,550 --> 00:10:31,000
There's a register, called ENV, which holds the environment
165
00:10:31,000 --> 00:10:34,070
in which this expression is to be evaluated.
166
00:10:34,070 --> 00:10:38,240
And, again, I made a pointer. The environment is some data structure.
167
00:10:38,240 --> 00:10:40,425
There's a register, called FUN, which will
168
00:10:40,425 --> 00:10:44,350
which will hold the procedure to be applied when you go to apply a procedure.
169
00:10:44,350 --> 00:10:47,325
A register, called ARGL,
170
00:10:47,325 --> 00:10:50,200
which wants the list of evaluated arguments.
171
00:10:50,200 --> 00:10:53,140
What you can start seeing here is the basic structure of the evaluator.
172
00:10:53,140 --> 00:10:54,490
Remember how evaluators work.
173
00:10:54,490 --> 00:10:57,670
There's a piece that takes expressions and environments,
174
00:10:57,670 --> 00:10:59,100
and there's a piece that takes
175
00:10:59,100 --> 00:11:03,480
functions, or procedures and arguments.
176
00:11:03,480 --> 00:11:07,294
And going back and forth around here is the eval/apply loop.
177
00:11:07,294 --> 00:11:10,000
So those are the basic pieces of the eval and apply.
178
00:11:10,000 --> 00:11:11,610
Then there's some other things, there's continue.
179
00:11:11,610 --> 00:11:15,340
You just saw before how the continue register is used to
180
00:11:15,340 --> 00:11:18,750
implement recursion and stack discipline.
181
00:11:18,750 --> 00:11:23,925
There's a register that's going to hold the result of some evaluation.
182
00:11:23,925 --> 00:11:26,555
And then, besides that, there's one temporary register,
183
00:11:26,555 --> 00:11:29,280
called UNEV, which typically, in the evaluator,
184
00:11:29,280 --> 00:11:30,625
is going to be used to hold
185
00:11:30,625 --> 00:11:33,950
temporary pieces of the expression you're working on,
186
00:11:33,950 --> 00:11:37,150
which you haven't gotten around to evaluate yet, right?
187
00:11:37,150 --> 00:11:40,646
So there's my machine: a seven-register machine.
188
00:11:40,646 --> 00:11:42,981
And, of course, you might want to make a machine with
189
00:11:42,981 --> 00:11:44,846
a lot more registers to get better performance,
190
00:11:44,846 --> 00:11:48,480
but this is just a tiny, minimal one.
191
00:11:48,480 --> 00:11:49,780
Well, how about the data paths?
192
00:11:49,780 --> 00:11:55,100
This machine has a lot of special operations for LISP.
193
00:11:55,100 --> 00:12:00,120
So, here are some typical data paths.
194
00:12:00,120 --> 00:12:03,320
A typical one might be, oh, assign to the VAL register
195
00:12:03,320 --> 00:12:06,710
the contents of the EXP register.
196
00:12:06,710 --> 00:12:11,900
In terms of those diagrams you saw, that's a little button on some arrow.
197
00:12:11,900 --> 00:12:13,699
Here's a more complicated one.
198
00:12:13,699 --> 00:12:18,810
It says branch, if the thing in the expression register is
199
00:12:18,810 --> 00:12:23,550
a conditional to some label here, called the ev-conditional.
200
00:12:23,550 --> 00:12:26,230
And you can imagine this implemented in a lot of different ways.
201
00:12:26,230 --> 00:12:30,600
You might imagine this conditional test as a special purpose sub-routine,
202
00:12:30,600 --> 00:12:33,845
and conditional might be represented as some data abstraction
203
00:12:33,845 --> 00:12:36,610
that you don't care about at this level of detail.
204
00:12:36,610 --> 00:12:37,980
So that might be done as a sub-routine.
205
00:12:37,980 --> 00:12:40,900
This might be a machine with hardware-types,
206
00:12:40,900 --> 00:12:45,350
and conditional might be testing some bits for a particular code.
207
00:12:45,350 --> 00:12:46,417
There are all sorts of ways that's
208
00:12:46,417 --> 00:12:50,190
beneath the level of abstraction we're looking at.
209
00:12:50,190 --> 00:12:53,247
Another kind of operation, and there are a lot of different operations
210
00:12:53,247 --> 00:12:56,840
assigned to EXP, the first clause of what's in EXP.
211
00:12:56,840 --> 00:12:59,260
This might be part of processing a conditional.
212
00:12:59,260 --> 00:13:04,258
And, again, first clause is some selector whose details we don't care about.
213
00:13:04,258 --> 00:13:06,300
And you can, again, imagine that as a sub-routine
214
00:13:06,300 --> 00:13:09,180
which'll do some list operations, or you can imagine that as
215
00:13:09,180 --> 00:13:12,170
something that's built directly into hardware.
216
00:13:12,170 --> 00:13:15,222
The reason I keep saying you can imagine it built directly into hardware
217
00:13:15,222 --> 00:13:18,360
is even though there are a lot of operations,
218
00:13:18,360 --> 00:13:19,740
there are still a fixed number of them.
219
00:13:19,740 --> 00:13:22,370
I forget how many, maybe 150.
220
00:13:22,370 --> 00:13:26,167
So, it's plausible to think of building these directly into hardware.
221
00:13:26,167 --> 00:13:28,275
Here's a more complicated one.
222
00:13:28,275 --> 00:13:31,500
You can see this has to do with looking up the values of variables.
223
00:13:31,500 --> 00:13:35,550
It says assign to the VAL register the result of looking up
224
00:13:35,550 --> 00:13:39,025
the variable value of some particular expression,
225
00:13:39,025 --> 00:13:42,600
which,in this case, is supposed to be a variable in some environment.
226
00:13:42,600 --> 00:13:46,280
And this'll be some operation that searches through
227
00:13:46,280 --> 00:13:49,325
the environment structure, however it is represented,
228
00:13:49,325 --> 00:13:52,019
and goes and looks up that variable.
229
00:13:52,019 --> 00:13:55,790
And, again, that's below the level of detail that we're thinking about.
230
00:13:55,790 --> 00:13:57,300
This has to do with the details of
231
00:13:57,300 --> 00:14:00,075
the data structures for representing environments.
232
00:14:00,075 --> 00:14:03,679
But, anyway, there is this fixed and finite number
233
00:14:03,679 --> 00:14:06,325
of operations in the register machine.
234
00:14:08,500 --> 00:14:11,720
Well, what's its overall structure?
235
00:14:11,720 --> 00:14:14,675
Those are some typical operations.
236
00:14:14,675 --> 00:14:16,442
Remember what we have to do,
237
00:14:16,442 --> 00:14:20,172
we have to take the meta-circular evaluator--
238
00:14:20,172 --> 00:14:22,767
and here's a piece of the meta-circular evaluator.
239
00:14:22,767 --> 00:14:28,050
This is the one using abstract syntax that's in the book.
240
00:14:28,050 --> 00:14:33,500
It's a little bit different from the one that Jerry shows you.
241
00:14:33,500 --> 00:14:37,874
And the main thing to remember about the evaluator is that
242
00:14:37,874 --> 00:14:43,425
it's doing some sort of case analysis on the kinds of expressions:
243
00:14:43,425 --> 00:14:48,560
so if it's either self-evaluated, or quoted, or whatever else.
244
00:14:48,560 --> 00:14:50,864
And then, in the general case where
245
00:14:50,864 --> 00:14:53,550
the expression it's looking at is an application,
246
00:14:53,550 --> 00:14:55,750
there's some tricky recursions going on.
247
00:14:55,750 --> 00:15:00,730
First of all, eval has to call itself both to evaluate the
248
00:15:00,730 --> 00:15:05,880
operator and to evaluate all the operands.
249
00:15:05,880 --> 00:15:10,850
So there's this sort of red recursion of values walking down the tree
250
00:15:10,850 --> 00:15:12,270
that's really the easy recursion.