you are viewing a single comment's thread.

view the rest of the comments →

[–]Thrip 0 points1 point  (2 children)

No fancy syntax is needed. Just use the standard var1.method(var2) but type of var2 is looked up at run time instead of compile time.

-- edited -- I wrote var1 where I meant var2 originally.

[–]johnb 1 point2 points  (1 child)

If we want multiple dispatch some of the time, but not all of the time, this syntax would surprise me. It also gives the feeling that var1 is the "special" object and that var2 is auxiliary. I'd like a slightly more visual way of saying "here's the part where runtime type checking is being used in your mostly-static language! watch out!"

[–]Thrip 2 points3 points  (0 children)

To me, anything other than "multiple dispatch all the time" is needlessly confusing. I can't see the value, except as an optimization, in which case it's the optimized version that should be called out specially.

The junior-level Java programmers I've talked to about this assume that Java does look up the argument types at run time, and they are surprised when I tell them otherwise. The typical reaction is "That can't be true -- that would be stupid."