• Post Reply Bookmark Topic Watch Topic
  • New Topic

Symmetric multiple dispatch, binary methods  RSS feed

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is written in a language that has symmetric multiple dispatch - methods are defined outside classes, and dispatch dynamically on all arguments regardless of order. There is no designated receiver for a method but rather all arguments are of the same priority. The runtime selects the most specific method to dispatch according to all arguments, and so there must be a single best implementation for each possible invocation of a method. The return type is not considered in the implementation selection. When compiling a package the compiler analyzes all types used in the package and all methods and makes sure that for each method and argument types combination there is a single best method to be called - or issues an error if that is not the case.

Say that I have three different packages and classes, all with an add() method.

I have written the following client:

There would be a problem in allowing this client to compile in a type safe multiple dispatch language, but which requirement could I relax so that this call is valid, assuming that dispatch must remain completely symmetric?

And what could be done in the client package, in order to resolve the problem, without modifying other packages and without relaxing the requirement mentioned above? What is the conceptual problem with this resolution?

Thanks for all help!
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!