I have not seen Borland specs, but it seems that I independently
arrived at similar rules.
Let me consider few cases. Simplest is exact match overload --
types of arguments match exactly function arguments. I think
we want to allow all such overloads. For example:
type month_no = 1..12;
servo_pos = 0..1000;
for month_no modular increment may be more natural, for servo_pos
intement should "stuck" at max value (both are differnt that normal
increment). In general, we may want to have colletion of types and
equip each one into given set of operations. I do not like discrimnating
against subranges here...
Next, we may distinguish between say strings and integers. In such
case it is natural to allow subranges in place of integer arguments,
and use just assignment compatibility.
For objects, "standard" reasoning (assuming single inheritance) is:
child is more special than parent, has all parent features, so
child can appear when parent can apper. Hence, we would like to
use most specific overloaded function, going up inheritance chain.
We would like to avoid introducing many special cases, so for subranges
it is also natural to take most specific one.
Of course, with multiple arguments (and also for subranges), "more specific"
is only partial order, so it may fail to uniquely determine outcome. Also
multiple inheritance (even such as in Object Pascal) breaks linear order.
I see the following solutions here:
1) forbid "unorderd" overloads (not so bad because one can force choice
using casts, and such cases should be rare anyway)
2) impose some arbitrary order
By the way, is 'var' parameter is used to produce a value, then exact
match is requred which may in turn force many extra overloads. In such
case 'copy in, copy out' parameters are more natural (or Ada 'in out').
--
Waldek Hebisch
hebisch(a)math.uni.wroc.pl