Frank Heckenbach wrote:
CBFalconer wrote:
... snip ...
Assignment compatibility (as far as I understand it) is no problem. array1 and array2 are of the same type and therefore compatible, and any other array type is not compatible. Remember that two identical looking structured type declarations are not compatible in Pascal, e.g.:
var a: array [1 .. 10] of Integer; b: array [1 .. 10] of Integer; [...] a := b { WRONG }
True, although I always forget that. Back in the days of the first standards there were long arguments about the definition of assignment compatibility. The other attack is that they are compatible if all their components are compatible (and declared in the same order for records).
I'm glad they chose the other route. Makes type-checking quite a bit easier and, more importantly, possible at compile-time, even in such complex situations.
PascalP (out of P4) took the compatible components route, and it was quite a simple recursive function, something like:
IF primitive THEN compatible := (t1 = t2) AND (t1.lim = t2.lim) ELSE IF arrt THEN compatible := compatible(t1.ixt, t2.ixt) AND compatible(t1.ct, t2.ct) ELSE IF rect THEN ...