I don't know how to phrase this better, but I remember reading an article about type theory, that categorized the values being received by a function and the values being sent back from the functions.
The example was something like:
T2 function(arg T1)
In this example
T1 would be a received type, and
T2 would be a sent type. And the rule of thumb for engineers was "make
T1 as generic as possible, since it is 'received', and
T2 as specific as possible since it is 'sent'." For example:
Array<int64> function(arg Iterable<Number>)
The goal is for the caller to use any type they want but fits the function, and use all the available methods from the returned value.
It was getting trickier with callbacks, for example, in the case of:
T3 function2(callback Callback<T1, T2>) # Callback takes T1 and returns T2
T1 is the sent type, and
T2 was the type received. So
T1 should be as specific as possible, while
T2 should be as generic as possible.
The reasoning behind it was that
T1 is "generated" by the
function2, while T2 is "passed" to
I know that there is a "scientific" name on whether the value of the type is "sent" or "received" by the function, but I can't find it.