buschman@tubsibr.uucp (Andreas Buschmann) (04/25/91)
Hello, here is another question about OBJECTs. suppose we have the following declarations: TYPE O1 = OBJECT METHODS m () : INTEGER := zehn END; TYPE O2 = O1 OBJECT m : INTEGER := 2 END; PROCEDURE zehn (self : O1): INTEGER = BEGIN RETURN 10; END zehn; what is the meaning of O2.m in the following block? a) O1's default method m (zehn) b) O2's default value for m (2) c) this is illegal d) something else in the report on page 39 there is the sentence r.f, o.f, I.x, T.m, E.id ... If T is an object type and m is the name of one of T's methods, then T.m denotes T's default m method. the SRC compiler v1.6 says types not assignable if i try to assign the value of this to an integer or a procedure variable. Tschuess Andreas
kalsow (Bill Kalsow) (05/07/91)
> suppose we have the following declarations: > > TYPE O1 = OBJECT METHODS m () : INTEGER := zehn END; > TYPE O2 = O1 OBJECT m : INTEGER := 2 END; > > PROCEDURE zehn (self : O1): INTEGER = > BEGIN RETURN 10; END zehn; Then, "O2.m" is illegal. Page 13 of the report says A field or method in a subtype masks any field or method with the same name in a supertype. So, if anything O2.m would name the INTEGER field, but the report does not attach a meaning to "ObjectType.Field". The lack of an error message when you try to use "O2.m" is a compiler bug. - Bill Kalsow