Post by thiagoatWho could say which to me would be the variancia of types that occurs in
the Oberon language?
In the original Oberon there were only record fields and no methods.
The field types are always invariant with respect to subtyping.
In Oberon-2, methods are introduced, but their types are invariant as
well.
In Component Pascal the rules were correctly relaxed to allow
covariance of method results. As far as I know, the possible
contravariance of input parameters has been ruled out because of
problems with pointers:
Consider B is a subtype of A, X is a subtype of Y:
PROCEDURE (a: A) P (VAR x: POINTER TO X; y: POINTER TO X), EXTENSIBLE;
...
PROCEDURE (b: B) P (VAR x: POINTER TO X; y: POINTER TO Y);
BEGIN
NEW(y);
(* Here we can get a POINTER TO X and make it refer to a Y object.
This becomes a disaster when x and y are passed the same pointer,
so the assignment propagates back to the caller.
UNSOUND!!! LOOPHOLE!!!
*)
...
END P;
In fact, the problem is that value parameters are mutable. Once
something is mutable, subtyping is a non-topic!
Regards, Andy