How should overruling of overloaded functions work?

Søren J. Løvborg web at kwi.dk
Mon Aug 21 08:44:58 PDT 2006


> I am also left wondering how often this concern actually manifests itself. 
> Is it purely theory with no practice? Would Sun silently slip in something 
> like an addAll function to HashSet later? How much has the C library 
> changed over time? How relevent is C's past to the future of more recent 
> languages?

Well, as of Java 1.2, with the introduction of the unified Collection 
framework, the addElement() method of Vector was superseded by a new method, 
add().

addElement() stays, however, for backwards compatibility, and isn't even 
deprecated (for reasons only known to Sun...)

Unless add() simply redirects to addElement(), old code that only overrides 
addElement() will be broken.

A quick test (with Sun's Java 1.6 beta) shows that in fact, neither method 
calls the other one. Old code could indeed be broken by this.

So, yes, such library changes happens. Which I guess is sort of an argument 
for retaining the C++ overload hiding rules. (Yet, I still think they're 
unneccessary.)

Søren J. Løvborg
web at kwi.dk 





More information about the Digitalmars-d mailing list