Lecture 7A: Metacircular Evaluator, Part 1

Channel:MIT OpenCourseWare · Length:1:24:37 · Published:2019-08-22 · Views:31670

Watch on YouTube

Summary

Lecture 7A from MIT 6.001 (SICP) by Abelson and Sussman introduces the metacircular evaluator, a Scheme interpreter written in Scheme. It shows how evaluating a program is itself a program.

Why HN recommends it

HN holds the SICP lectures up as joyful classics, and this lecture as the moment the evaluator is revealed.

But mostly it just makes me happy - it's infectious and weird. — HN, 2020

Functional programming · Compilers, interpreters & program analysis · University lectures & courses

Subtitles (excerpt)

PROFESSOR: Well today we're going to learn about something quite amazing. We're going to understand what we mean by a program a little bit more profoundly than we have up till now. Up till now, we've been thinking of programs as describing machines. So for example, looking at this still store, we see here is a program for factorial. And what it is, is a character string description, if you will, of the wiring diagram of a potentially infinite machine. And we can look at that a little bit and just see the idea. That this is a sort of compact notation which says, if n is 0, the result is one. Well here comes n coming into this machine, and if it's 0, then I control this switch in such a way that the switch allows the output to be one. Otherwise, it's n times factorial of n minus one. Well, I'm computing factorial of n minus one and multiplying that by n, and, in the case that it's not 0, this switch makes the output come from there. Of course, this is a machine with a potentially infinite number of parts, because factorial occurs within factorial, so we don't know how deep it has to be. But that's basically what our notation for programs really means to us at this point. It's a character string description, if you will, of a

On Hacker News

I re-watch this course every bunch of years, and every time I get something different from it. But mostly it just makes me happy - it's infectious and weird. Especially the "revelation" (spoiler!) [VIDEO] — mrspeaker, 2020-06
"We're getting really close to the spirit of the computer at this point, so I have to show a certain amount of reverence and respect" [VIDEO] — ufo, 2023-09
I learned best in Scheme because you don't need to parse your input and can just evaluate a tree[0] (Parsing is, in my opinion, the most boring part about writing an interpreter!) Chapter 7 of Crafting Interpreters lays out how an evaluator works in a pretty clean way [1]. I've also blogged about evaluating ASTs in JavaScript [2] Lastly, Gary Bernhardt took it a step further and instead of "evalu… — prezjordan, 2021-07

Related videos