Function overloading: Difference between revisions

Content deleted Content added
Line 44:
Sometime overloading wrongly taken as a classification of static polymorphism in which a function call is resolved using some "best match" algorithm, where the particular function to call is resolved by finding the best match of the formal parameter types with the actual parameter types or/and number of parameters.
The mistake comed from confusion in each form of static polymorphism as following:
* ''[[Parametric polymorphism]]'' differdiffers from overloading by that the function definition exists only ones and this function invoked with parameters of different types which are substituted formal parameter types.
* ''[[Ad hoc polymorphism]]'' is very similar to overloading but it's depends of a language. This classification was introduced by [[Christopher Strachey]] in 1967, but difference is that he applied for compiler specific features which was exists in some programming languages. It was possibly to define in a module only name of a function and have in another module a multiple functions with same name(exact [[Function overloading|function overloading]]) so one module doesn't have access to another module until compiled. Thus was created effect that in first module was used same function for different parameters but it was just a cosmetic effect therefore [[Christopher Strachey]] gave it such special name as "ad hoc". But not any language has same feature, e.g. in [[Java (programming language)|Java]], there is no possibility define such function, similar example in Java can be achieved by using common interface for both modules but interface should have exact function signature thus ''[[Ad hoc polymorphism]]'' can't be applied.