Lecture 16
Variables, Scope, Pairs, Mutation
Programming Languages
UW CSE 341 - Spring 2021
Local Bindings
let expression
let*
letrec
letrec for mutual recursion
Local define
Our Style
Top Level
REPL
Unfortunate optional detail you hopefully won’t run across:
Cons
The Truth About cons
The Truth About cons
Mutation
set!
(set! x e)
(begin e1 e2 … eN)
set! Example
Top-level set!
then nobody outside that file (module) can either
cons cells are immutable
set! does not mutate list contents!
Instead, set! changes which immutable list x points to
Mutable Lists & Pairs [moved to section]
Run-time errors:
(car (mcons 1 2))
(mcar (cons 1 2))