Some time ago we had a discussion here about interfaces and generics and we said that when we declare interfaces with generics there is no need to add a GUID.
Some time ago we had a discussion here about interfaces and generics and we said that when we declare interfaces with generics there is no need to add a GUID.
So, I have to write this:
IInterface1 = interface
['{...}']
end
and this:
IInterface2 = interface
//no GUID here
end;
So, if I declare this interface do I need a GUID or not?
IAnotherInterface = interface (IInterface2)
//GUID here???????
end;
Thanks
So, I have to write this:
IInterface1 = interface
['{...}']
end
and this:
IInterface2
//no GUID here
end;
So, if I declare this interface do I need a GUID or not?
IAnotherInterface = interface (IInterface2
//GUID here???????
end;
Thanks
John Kouraklis The compiler does not generate a GUID based on anything - the developer declares it. Anyway I disagree that you should not give GUIDs to generic interfaces. What you should avoid is calling Supports on a generic interface in some non generic place or a place where you suddenly could get a TList as IList.
ReplyDeleteAnyway at least since XE2 (I think) there is some additional typeinfo inside a class that gives you the typeinfo of each implemented interface. I used that to make a Supports function that is not based on TGUID but on PTypeInfo.
Stefan Glienke If you're not going to call Supports (or friends), what use is the GUID for?
ReplyDeleteI wrote calling it in a non generic environment. If you for example inside TFoo call supports(IBar) then this is fine. If you call supports(IBar) on some IBar reference this is not.
ReplyDelete