Prof A Olowofoyeku (The African Chief) wrote:
That being said, I am not sure why one would want to overload routines using different subranges of integer. Just because the compiler allows something doesn't mean that one should do it, especially seeing that, in such cases, one single routine (taking a parameter of the largest size of integer) would do just fine.
As I wrote, this may be done for efficiency (since passing an Integer is slightly faster than passing a LongInt, e.g.), but I'm also doubtful if it's a good thing to do.
A similar problem would appear with `Integer' and `Real', BTW, since integer values are allowable for `Real' (value) parameters. I'm not sure how important this is.
Though it might be, especially for operators. If we want to define a new numeric type, say GMP's real type, and provide regular operators for it, so we could do `GMPRealValue + IntegerValue' and `GMPRealValue + RealValue', we have just this situation.
Of course, defining an `GMPRealtype + Real' operator would accept an integer RHS operand as well, but it's less efficient than calling GMP's "GMP-Real + Integer" routine directly.
So perhaps one should allow integer vs. real ambiguities, since they're less fragile than those between different integer subranges?
Frank