Real-Life Scala Capture Checking
summary
Live-coding shows Scala’s experimental capture checking catching a real bug: a payment gateway returned inside a lambda escapes its scope and causes an error when invoked later. The compiler enforces capture sets so values tied to resources (a rate service, gateway) cannot leak, and distinguishes thin arrow (pure) vs thick arrow (impure) function types. The demo builds a payment/receipt flow, reproduces a pay‑later failure, and proves the compiler rejects unsafe captures so the code fails fast rather than silently misbehaving.
AI-written summary · about
chapters (10)
- 0:00Capture checking in Scala
- 1:48Payment service use case
- 6:46Refactoring to generic processor
- 8:54Resource leak bug demo
- 13:32Tracking values in scopes
- 16:00Dynamic fee functions
- 20:20Pure vs impure functions
- 23:49Capturing resources in functions
- 24:32Capture set types
- 30:38Summary
related talks
38mCapture Checking - A New Approach to Effect Safety in Scala
01h 03mInside the Scala Capture Checker
41mHands On Capture Checking with Martin Odersky
49mThe first steps towards practical capture checking
01h 03mWhere Are We With Scala's Capabilities?
01h 23mCapture Tracking in Scala
41mWhere Are We With Scala's Capabilities?
42mWhen your DSL Needs to Support User-Defined Functions
