views:

144

answers:

1

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!

+2  A: 

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.

Daniel
Ah; IDEA is pointing me at the wrong class. The question still stands though; where are the AbstractActor and msg coming from? And how is it ending up as an instance of the case class Exit?
oxbow_lakes
My code is basically "actor_ ! Exit". I'm not passing any variables to anything. And yet actor_ ends up getting sent the Exit(from,msg) case class with some lovely and accurate values. And how does the object Exit extend the binary function when it doesn't declare an apply() method?
oxbow_lakes
Ah, but Exit does declare an apply() method! It's type is "(AbstractActor, AnyRef) => Exit", which is the same thing as "Function2[AbstractActor, AnyRef, Exit]". Since Function2 declares an apply, then so must Exit.
Daniel