Lesson 21: set! and Tail Recursion
Outline:
- Special form:
set!- evaluating
set! set!vs.define
- evaluating
- Tail-call optimization
- what it is
- why it’s useful
- recognizing tail recursion
- Wrap-up
What’s next
Upcoming events/assessments:
- CS Bits and Bytes Thursday at 3:30pm in Anderson 329
- Interpreter Parts 4+5 cannot be resubmitted after next Monday at 10pm
- Exam Day 2 will be this Friday (includes Quiz 6 and all other LOs we’ve seen so far)
What you should do now:
- Read the assigned readings (see below)
- Finish Interpreter Part 4: Parser if you haven’t already
- Complete Interpreter Part 5: Evaluating if/let/quote
- Start Interpreter Part 6: Evaluating define/lambda
Reading assignment (to be completed by the next class):
Tail calls (from today):
- Tail calls – stop at “Tail recursion modulo cons”
For next time:
- Read this opinion piece on why Python doesn’t have tail-call optimization (a.k.a. tail recursion elimination)