> On Tue, 22 Mar 2005, ml wrote: > > // than one interface > > a := (object as IA); // correct > > b := (object as IB); // returns pointer to the first interface vmt=IA > > c := (object as IC); // returns pointer to the first interface vmt=IA > > // there's no way to do again it's like direct call to exception > > obj := a; // returns pointer(obj) + 12 ??? > > This is nonsense. You cannot assign an interface to a class. > A class IMPLEMENTS an interface, it is not an interface.
Ml, see my original message. If you have an interface, you know nothing of the stuff the class adds outside that interface. Assigning/converting an interface to a class is impossible, which can be shown by this example. Var intf : IA; // has method C cl : SomeClass; // has method A,B begin intf:=someclass.create; // get reference to list with methods of interface cl:=intf; // assign list with methods of interface to // list of methods of class. cl.a; // cl has no knowledge about anything .c this // can't work. end; Even though at the point of "someclass.create" all info about the class is available, only a list of offsets for methods in the interface is passed. (so only method C at offset 0 in that table) When assigning intf to cl, you assign that table back to the cl, the full which needs a full VMT, with info about A and B. This makes the third statement (cl.a) impossible. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal