Ted Neward wrote: [...] > Gosling, on the other hand, felt that C++'s approach to virtual method > dispatch was inconsistent--that at any given point in the object's > lifetime, the dispatch resolution for a virtual method should > always be > the same, regardless of whether you're in a constructor or not. Again, > not really much to do with efficiency as it was with language purity. > (Remember, the compiler could, within a constructor, emit an > "invokespecial"--the JVM equivalent to a "call"--instead of a > "invokevirtual"--the JVM equivalent to "calli"--for any method call on > this class while called from within a constructor body. > "Invokespecial" > (and its CLI equivalents) can effectively bypass virtual method > dispatch, so it's not impossible to do if they wanted to.)
What if the method in turn calls another virtual method? There is no way to elegantly and efficiently implement the C++ behavior in Java or C#. BTW, the CIL equivalent to invokevirtual is callvirt, not calli. Regards, Jeroen