title: Alternatives to using "var" for state with actors?
body: <p>I have found myself using vars fairly often with akka actors to maintain state. For example, if I my actor needs to maintain a list of items, I might do something like:</p>
  
  <pre><code>class ListActor extends Actor{
    var xs : List[Int] = List()
  
    def receive = {
      case x : Int =&gt; xs = x :: xs
    }
  }
  </code></pre>
  
  <p>Using the mutable variable seems to go against the spirit of Scala. Alternatively I have used this:</p>
  
  <pre><code>class ListActor2 extends Actor{
    import context._
  
    def collect_ints(accu : List[Int]) : Receive = {
      case x : Int =&gt; become(collect_ints(x :: accu))
    }
  
    def receive = collect_ints(Nil)
  }
  </code></pre>
  
  <p>I like how this looks more, but do I have to worry about the stack overflowing? </p>
  
  <p>I am aware of the FSM trait and have used that before also, but for some situations it seems like too much. </p>
  
  <p>What is the recommended way of maintaining simple state? Are there other alternatives that I am unaware of?</p>
  
  <p>Also, is it generally a bad sign if I find myself needing mutable variables often? Am I not using the actor model properly?</p>