Actors typcially required state that are var-declarations.; e.g., to hold a 
sum in an accumulator. What's the best way to do this without 
var-declarations? 

One that comes to mind is to keep 'becoming' a new behavior as shown below. 
Is this efficient? Is there a pattern to write the *receive *method without 
the auxillary *morph *method?

Enter code here...
class FunctionalActor(val sum: Int) extends Actor {
    def morph(sum: Int) : Receive = {
        case "inc" => 
            context.become(morph(sum+1))
        case "report" => 
            sender() ! sum
            context.become(morph(0))
    }

    def receive : Receive = morph(sum)
}

Thanks.

Lal

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to