tag:blogger.com,1999:blog-3322141.post115140208643934611..comments2023-10-24T23:22:27.416+10:00Comments on More News: Revisiting VisitorUnknownnoreply@blogger.comBlogger1125tag:blogger.com,1999:blog-3322141.post-1151554786849144832006-06-29T14:19:00.000+10:002006-06-29T14:19:00.000+10:00Hi Andrew,It would be really good to see some mult...Hi Andrew,<BR/><BR/>It would be really good to see some multiple dispatch in Java 6. <BR/><BR/>Currently all private and (obviously) static method calls use the invokestatic instruction where any protected/public method invocations use the invokevirtual instruction. <BR/><BR/>Unfortunately the invokevirtual instruction is only bound against the runtime type of the object that the method is called on. There is no way to invoke a method based on the runtime type of it's arguments (well it can be done using a proxy that involves a method table and name mangling but is quite messy).<BR/><BR/>It would be really nice to see an "invokedynamic" instruction added to the JVM that could evaluate the runtime type of the method arguments. To utilise it, there would need to be a keyword added to the java language to indicate that this type of dynamic binding should be used (as it would be less efficient than standard method binding). <BR/><BR/>This would remove the need of applying the Visitor pattern in cases where it is used to implement method invocation that is based on the runtime-type of the method argument(s). It would also remove the need for explicit invocation of methods based on runtime argument type using the "instanceof" operator .<BR/><BR/>RobRobhttps://www.blogger.com/profile/14244395854512282492noreply@blogger.com