[fpc-pascal] Overloading functions

leledumbo leledumbo_cool at yahoo.co.id
Wed Sep 10 17:38:27 CEST 2014

> Now FPC could obviously do that with e.g. an overloaded := operator. But 
> is there any way to handle the special case of two functions, one of 
> which returns a dynamic array and the other the number of elements, 
> without having to give them different names or parameters? 

With the availability of casts (including OOP style casts), I don't think
it's possible to overload simply from return type. Even in the current
implementation, there are cases when the compiler can't decide which
overloaded function to call. For instance, when the same parameter position
of two functions are on the same inheritance line. Moreover, return values
don't need to be assigned, it can be safely ignored. In that case, which
overloaded function one has to call?

Your case doesn't worth overloaded function, as the returned values has
different meaning.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Overloading-functions-tp5720000p5720001.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

More information about the fpc-pascal mailing list