Intermezzo: Spores
Spore [3] = closure
• with explicit environment
• with function type refined by captured types
val msg = "hello"
val num = 5
spore {
val s = msg
val x = num
(p: Int) =>
s”Captured vars and param: $s, $x, $p”
}
Spore[Int, String] {
type Captured = (String, Int)
}
22
[3] Miller, Haller and Odersky. Spores: a type-based foundation for closures
in the age of concurrency and distribution. ECOOP ’14