// *** before: ***
// there was no supported way back from an interface reference to the
// object behind it, so the interface carried an extra method for it
type
IPerson = interface
['{9E8C4A20-1F2E-4C7A-9B41-7B6F2D5A18C3}']
function GetSelf: TObject;
function GetName: string;
end;
var
Intf: IPerson;
Obj: TObject;
begin
Obj := Intf.GetSelf; // every interface needed its own hatch
end;
// *** in version 2010: ***
type
IPerson = interface
['{9E8C4A20-1F2E-4C7A-9B41-7B6F2D5A18C3}']
function GetName: string;
end;
var
Intf: IPerson;
Obj: TObject;
begin
Obj := Intf as TObject; // the compiler and the RTL do it for you
if Obj is TPerson then
Writeln(TPerson(Obj).ClassName);
// careful: the object is still owned by the reference count of the
// interface, so do not free what you got this way
end;