Question

Will method-handle objects directly provide the ability to invoke methods using multiple-dispatch. If so, is only double-dispatch supported, or will the dispatching mechanism take as many arguments as necessary into account? If multiple dispatch is supported, any code examples would be particularly appreciated.

Thanks in advance,
Mackenzie

Was it helpful?

Solution

I doubt it. It is not listed on the OpenJDK feature list http://openjdk.java.net/projects/jdk7/features/, and I have seen nothing suggesting its inclusion. Also, this question already tops the google search for "Java 7 multiple dispatch." Stack overflow has exception SEO, but that suggests almost no discusion. Also, multiple dispatch is inherently slower, and would require both JVM and language changes to make work well, so I dont see it being included in the near term.

Note: the visitor pattern can be used to avoid much of the need for multiple dispatch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top