4 ms·
Actors are good at encapsulating state, therefore using mutable variales inside an actor through is very natural, and one might even question if an actor is nee
by wernerb 12y ago
Actors are good at encapsulating state, therefore using mutable variales inside an actor through is very natural, and one might even question if an actor is needed if it does not have any mutable state inside it.
However, 5.2 does not concern the elimination of vars, but rather better management of multiple states (Finite state machines)
Your example, just like the example in 5.2, only has a single state, so no context.become is strictly necessary. The author makes clear that when you have multiple states, the collection of top-level mutable vars will be hard to maintain. I had this problem a few times and I am glad this gets mentioned in the guide.
I agree though, that a better example would include at least two states.
- bad_user 12y agoI'll add a better example, thanks for the feedback.