Is a set of functions that perform exactly one word, but different from a name like atoi , atol , atoll , etc., called theoretically polymorphic?
For example, I have a say swap function that should work with various data types. Therefore, I have one function / operation for which I have different implementations, but, unfortunately, because the language does not support the use of the same function name, to get such functionality, I need to make options swap_i , swap_l , swap_f , swap_str etc etc. and call them manually depending on the operands.
When developing code, one could design this as one function with various implementations that are called depending on the operands. But in this case, instead of the compiler, the programmer needs to make a static binding of functions. If a programmer implemented it in C ++, then the design would be the same (as he / she followed the OOD approach), but in this case the static binding can be done by the compiler without disturbing the user.
Now, if there was a polymorphic function in the swap design approach, would such a difference in the implementation of the C and C ++ design matter, so we cannot call such an implementation of C not polymorphic, but the C ++ implementation polymorphic?
EDIT1:
Another example:
let's say we send a union with the various possible data types packed into it, and a structure wrapping it with a variable indicating which component of the union will be used. Then we can use only one swap function name with no options. After we get the structure in the function, we can internally perform operations depending on the type of data active in the union
struct _generic { int type; union { int a; float b; char c; } component; } variable; swap (struct _generic var2, struct _generic var1) { if (var1.type == INTEGER) { } else if (var1.type == FLOAT) { } . . . }
In this case, we use a different method.
Also pay attention to the ellipse operator ... , as in printf , with this you can also get some built-in function.
The main thing is that the C language does not provide a direct implementation of OOD s, but can we use the OOD terminology for implementation in a C implementation if it is developed using object-oriented design?