Why isn't ask defined directly on ActorRef for Akka?

Tha*_*yne 7 scala akka

I am learning about Akka, and while exploring the API, I came across something kind of curious (at least to me). The tell function is defined directly on the ActorRef class. However, the ask function is declared in the AskSupport trait. I can't think of any good reasons why they needed a seperate trait for AskSupport rather than including ask in the API for ActorRef (and ? in the API of ScalaActorRef). Would anyone care to enlighten me on the reasoning behind this?

Rob*_*ier 4

Actor 文档给出了作者的推理:

Ask 模式涉及 Actor 和 Future,因此它作为使用模式而不是 ActorRef 上的方法提供

Ask 模式包括 Future 扩展,而不仅仅是 ActorRef 扩展。特别是,如果您查看 akka.pattern 文档,您会注意到PipeToSupportAkkaPipeableFuture对象的扩展。