Hi all,
I’m working on a personal numerical libray in Fortran. I want to overload my functions so that they can be called with arguments of any numeric type. I have several questions about this.
As an example, assume a function with two arguments that can be integer or real: fcn(arg1,arg2). The possible ways to call this function would be fcn(real,real), fcn(real,int), fcn(int,real), fcn(int,int).

Do I have to rewrite my function (or write a shell) for every possible combination of argument types? With increasing number of arguments, the number of functions to be written would grow rapidly. Is there a better way to do this?

Say I define an interface for these four functions above. What if my second argument is optional? Say the function would be called with only the first argument which is a real, the compiler would not know how to to choose between the fcn(real,real) and fcn(real,int) versions.

What if I want the function return value to be with the same precision (i.e the same kind parameter) as the input (or say the input with the highest precision)? Do I have to overload my function for that as well?
Thanks in advance for any advice.
Best,
Maarten