ddimtirov / nuggets

nuggets is (yet another) utility library for Java
https://ddimtirov.github.io/nuggets/javadoc/io/github/ddimitrov/nuggets/package-summary.html
Apache License 2.0
4 stars 1 forks source link

Multi-dispatch for functional objects #20

Closed ddimtirov closed 7 years ago

ddimtirov commented 8 years ago

Multiple dispatch or multimethods is a feature of some programming languages in which a function or method can be dynamically dispatched based on the run-time (dynamic) type or, in the more general case some other attribute, of more than one of its arguments.

ddimtirov commented 7 years ago

I tried, but I couldn't come up with a natural looking API for implementing multiple dispatch in Java that would save work and increase the readability compared to just writing a naive switch statement or a series of if (x instanceof Y) doThis(x) else ... code.

I am giving up for the time being, but I tagged the leftovers with the nuggets-20-dead-end tag.