SICP Study

1.1 The Elements of Programming

There are three mechanisms for combining simple ideas to form more complex ideas found in every powerful programming language:

Programming deals with procedures and data (which are almost the same thing in Lisp). Procedures manipulate data.

1.1.1 Expressions

1.1.2 Naming and the Environment

1.1.3 Evaluating Combinations

Highlights

In the words of Alan Perlis, “Syntactic sugar causes cancer of the semicolon. (Footnote 1.11)

1.1.4 Compound Procedures

1.1.5 The Substitution Model for Procedure Application

This is the substitution model:

To apply a compound procedure to arguments, evaluate the body of the procedure with each formal parameter replaced by the corresponding argument. (Section 1.1.5)

An example of procedure application:

(f 5)
(sum-of-squares (+ 5 1) (* 5 2))
(sum-of-squares 6 10)
(+ (square 6) (square 10))
(+ 36 100)
136

Applicative order versus normal order

(f 5)
(sum-of-squares (+ 5 1) (* 5 2))
(+ (square (+ 5 1)) (square (* 5 2)))
(+ (* (+ 5 1) (+ 5 1)) (* (* 5 2) (* 5 2)))
(+ (* 6 6) (* 10 10))
(+ 36 100)
136

1.1.6 Conditional Expressions and Predicates

1.1.7 Example: Square Roots by Newton’s Method

But there is an important difference between mathematical functions and computer procedures. Procedures must be effective. (Section 1.1.7)

1.1.8 Procedures as Black-Box Abstractions

A user should not need to know how the procedure is implemented in order to use it. (Section 1.1.8)

Local names

Internal definitions and block structure