Crafting Interpreters · Week 7
Crafting Interpreters 13: Inheritance: reading guide
Read the chapterVerified by tests
Single inheritance: superclass declarations, method lookup through the chain, and super calls, finishing jlox.
Time About 5 hours this week
Why it matters
Method resolution order and super are how every OO language reuses code. Finishing jlox is a real milestone.
How to approach it
Implement, then run the full jlox test suite. Celebrate, then take a day before starting C.
Challenges
3 challenges at the end of the chapter.
Challenge 3 (implement a feature you listed back in chapter 3) is the most rewarding. Challenge 2 (BETA-style inner) comes back in chapter 29, so if you skip it now, expect to meet it again. Do challenges that change Lox's behavior on a separate git branch. The cracked.guide check runs the official test suite for this chapter, and a challenge that changes semantics (new syntax, different errors) can make tests fail on main.
Traps
- A class inheriting from itself: make sure it is an error.
- super lookups must use the superclass of the class where the method was defined, not of the instance.
Verified by the book's chap13_inheritance tests when you push your repo.