How to overload bang(!) operator in Scala Actor model?

后端 未结 3 1912
终归单人心
终归单人心 2021-01-20 02:56

In an Actor model implementation in Scala, can we override the bang(!) operator. Can we modify the operation of message passing by overloading this operator?

Example

3条回答
  •  面向向阳花
    2021-01-20 03:47

    In an Actor model implementation in Scala, can we override the bang(!) operator.

    You can, but I would strongly recommend against it.

    Example scenario: I need to include logging of information when any actor invokes another actor by passing a message.

    1. This won't work with any actors which don't extend your type: Akka system actors, actors created by libraries, etc.

    2. This can already be done by Akka, just set akka.debug.receive = on.

提交回复
热议问题