Scott Moore wrote:
Back on the original subject, the spec for Borlands version of overloads are just awful. Virtually any difference in type between overload parameter lists is accepted as a valid overload. For example, two subranges of integer are accepted, which is clearly an ambiguous overload. Borland "resolves" this by calling the procedure or function with the smallest integer range. Thats a recipe for fairly incomprehensible behavior for the user.
I think I agree. For me, that's still the major open question WRT overloading.
My idea would be to check (at call time) which routine is acceptable, and give an error if it's more than one. This would be unabmiguous. OTOH, it may be too strict for some purposes. E.g., if you want to have a version that accepts a normal `Integer' parameter and one with `LongInt' for extended ranges, you couldn't do this since a value that fits in `Integer' also fits into `LongInt', so such a call would be ambiguous.
Maybe that's the motivation of Borland's decision, but I'm still skeptical of it, since the results are quite fragile.
And it's debatable whether it's even desirable to implement two such versions. The compiler can't check that their implementations are equivalent, so the results could still be confusing, even if meant well. So perhaps we should not allow that indeed (since, after all, it's only a syntactic restriction -- one can always use different names for different routines, as we do now).
Frank