> BTW, the CIL equivalent to invokevirtual is callvirt, not calli. > Whoops, you're right, Jeroen, my bad--I knew calli didn't quite sound right, but couldn't think of what the other one was called, and was just too d*mn lazy to go check my CIL reference just to look up something I was going to use in passing reference. :-)
> 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#. > Well, yes, things would then get "interesting" from there, but I wouldn't be opposed to the compiler throwing up its hands and just leaving you to your fate at that point. Or even more insane behind-the-scenes magic could be used. The point here is, the three environments each had a choice to make, and they chose based on nothing more than principle, not performance. Ted Neward Author, Instructor, Presenter: Java and .NET http://www.neward.net/ted/weblog http://www.javageeks.com http://www.clrgeeks.com > -----Original Message----- > From: Moderated discussion of advanced .NET topics. [mailto:ADVANCED- > [EMAIL PROTECTED] On Behalf Of Jeroen Frijters > Sent: Friday, June 20, 2003 1:35 AM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Partially constructed objects in C# > > 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