diff --git a/sips/pending/_posts/2013-06-10-spores.md b/sips/pending/_posts/2013-06-10-spores.md index 60c6f3effb..ced4630e9a 100644 --- a/sips/pending/_posts/2013-06-10-spores.md +++ b/sips/pending/_posts/2013-06-10-spores.md @@ -172,19 +172,22 @@ We now revisit the motivating examples we described in the above section, this t ### Futures and Akka actors +The safety of futures can be improved by requiring the body of a new +future to be a nullary spore (a spore with an empty parameter +list). + Using spores, example 1 can be re-written as follows: def receive = { case Request(data) => - val s = spore { + future(spore { val from = sender val d = data () => { val result = transform(d) from ! Response(result) } - } - future { s() } + }) } In this case, the problematic capturing of `this` is avoided, since the result of `this.sender` is assigned to the spore's local value `from` when the spore is created. The spore conformity checking ensures that within the spore's closure, only `from` and `d` are used.