scalaactorremote-actors

How is Scala "filling in" missing arguments to a case class?


When I call:

actor_ ! Exit

How is this being converted into a construction of:

case class Exit(from: AbstractActor, reason: AnyRef)

In particular, how is it that when I call this from a remote (client) actor which has been linked to a remote (server) actor, that the server receives an instance of Exit where the from property is an actor:

'remotesender0@Node(10.10.7.90,8366)

Basically I'd like to figure out how I can get a handle on this remote-client-actor object!


Solution

  • What you are sending is the singleton object Exit. In the Scala API, just scroll down past the classes, and look up the objects.

    object Exit 
    extends (AbstractActor, AnyRef) => Exit
    

    Now, I haven't seen your code, so I don't know how you are using it. Notice, though, that this object Exit is (actually, extends) a function, which takes two parameters and returns an Exit case class formed by them. It will also have some stuff put in it by the case class statement.

    Or, in other words, Exit.apply(x,y) (the function Exit being applied) has the same result as Exit(x,y) (the constructor for class Exit). But while you can't pass a class, you can pass an object.