title: Concurrency Actors and Traits in Scala
body: <p>Folks,
    I'm new to Scala and am trying to figure something out. I've been messing around a bit with traits and I really like their ability to "mix in" functionality and interface. I've also been messing around with concurrency and Actors and I really like the ability I get to model highly complicated concurrent systems easily.</p>
  
  <p>The problem I'm having is I can't quite find a pattern for combining both worlds. What I'm really looking for is using traits to determine which types of messages an Actor responds to, allowing for different responses across inheritance hierarchies.</p>
  
  <p>So, to use a battlefield simulator example: I have Simulants, which are traits. All objects on the battlefield are Simulants, and Simulants should respond to "Ping" by sending "Pong" - this is it. I want an <code>IFF</code> trait, which will allow a simulant to identify itself as a friend or foe of the message sender. Another trait should be <code>Mobile</code>, which means the simulant can move and should respond to messages telling the simulant its new destination.</p>
  
  <p>As you can see, I might have : <code>class Tank extends Actor with Simulant with IFF with Mobile</code> , but I might have something like a barrier, e.g. <code>class Barrier extends Actor with Simulant</code>.</p>
  
  <p>What I have not yet been able to do is create the right combination of <code>act()</code> methods, loops, reacts, and so forth to make this scenario possible. In short, is it possible to "mix in message reactors" or does Scala limit me to choosing Actors with single inheritance or mixins without actors?</p>
  
  <p>Thanks!</p>