Structure and
Interpretation
of Computer
Programs

Fall 2021
course
site
-->

Mon Nov 1

I've posted an assignment due Thursday covering the material in sections 3.2 (local state) and 3.3 (mutable data) in the text.

We've already discussed 3.2 at some length; today we'll go over some of the ideas in 3.3.

And from there I'll give you a pep-talk about where we're headed next.

Questions about anything?

mutable data - section 3.3.

Discuss set-car! and set-cdr! , and the Guile vs DrRacket quirks to look out for, namely that these languages have "mutable pairs" and "immutable pairs", even though there isn't an easy way to test for the difference ... at least not in the "SICP compatible" version of the DrRacket language. From what I can read, the old SICP scheme only had mutable pairs. Lookup "racket mutable" for some of this stuff. In racket, mcons rather than cons is the mutable pair.

The upshot of this is that in the guile scheme, you should use (list 1 2 3) rather than '(1 2 3) to make mutable structures. And grow from (list ), not '() ... at least that's what worked for me.

Exercises to try in class: 3.15 set-to-wow! and 3.16 count-pairs.

coming attractions

Let's think over what we've done so far, and start to talk about the "big picture" of how that fits into the study of programming languages.

Next I want to pull back and take a look at how these ideas connect to all programming languages ... by talking about how to code a programming language using another programming language, namely "interpreters" and "compilers".

In SICP, some of this is covered in chapter 4 ... and we'll circle back to that, after first looking at the big picture.

I can give you the punch line now : the language we've been doing, lisp, is special in that the syntactic structure of the language makes the semantic structure obvious and trivial. It's really the only language family where the data structures (what we've been doing with list and cons) are made up of the same stuff as the programs (what we've been doing with define and lambda and all that). That means that in lisp, data and code look the same ... which means the tools to have your programming language manipulate your programming language are already right there in front of you.

So : let's start with two concepts.

(Language A is itself running on top of an operating system and some sort of assembly language D, but that is not the point here.)

All this is more common that you might think. In many cases you may want to invent your own domain-specific language (DSL) to handle some particular problem. Why do you think that there are 1500 programming languages at 99-bottles-of-beer.net ? Never mind all the non-programming languages like regular expressions, HTML, CSS, JSON, YAML, diff, and so on.

What are the pieces & steps involved in these compilers & interpreters? I'm glad you asked.

All of these are big topics, and in the month or so left this term we won't fully master them. But we can see some examples and understand how the ideas fit together.

I'll find us some small-ish problems for us to explore these themes, and will post some online resources soon, including

So ... stay tuned. ;)

https://cs.bennington.college /courses /fall2021 /sicp /notes /11-01
last modified Sun October 31 2021 11:41 pm