As a matter of fact, this is what confused me the most. In my previous experience, e.g. with java or php, I don't care about COM or CORBA, interface to me is just another way to implement abstract method for languages that do not support multiple inheritance. Isn't that the case?<br>
<br>The reason I asked the question initially was I try to implement Enumerator for my TTreap class so that I can use it in for... in loop. To do this, can I just implement the GetEnumerator method, or I have to define the class as this:<br>
<br>generic TTreap<TKey, TValue> = class(IEnumerable);<br><br>In another word, if I do not declare that the class implements IEnumerable, but just add the required method, will the language detect this and make my class enumerable?<br>
<br><br><div class="gmail_quote">2013/3/20 Graeme Geldenhuys <span dir="ltr"><<a href="mailto:graeme@geldenhuys.co.uk" target="_blank">graeme@geldenhuys.co.uk</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Dodi covered it all pretty much...<br>
<div class="im"><br>
On 2013-03-20 13:38, Xiangrong Fang wrote:<br>
><br>
> So, what is the purpose of this UUID and the method provided by<br>
> TInterfacedObject?<br>
<br>
</div>Only needed if you are doing COM programming under Windows. For the rest<br>
of the times you don't need it.<br>
<br>
Also note that sometimes it is beneficial having interface support, but<br>
without reference counting. In that case you can use CORBA-style interfaces.<br>
<br>
Simply add the following to your unit..<br>
<br>
{$mode objfpc}{$H+}<br>
{$interfaces corba} // <<-- New line<br>
<br>
type<br>
ITestInterface = interface<br>
[STestInterface]<br>
procedure DoSomething;<br>
procedure DoItAll;<br>
end;<br>
<br>
<br>
Now 'interface' in the type declaration will not be a IUnknown or<br>
IInterface descendant. Thus no need to use TInterfacedObject as a base<br>
class, TObject will suffice. I tend to use CORBA-style interfaces much<br>
more in my applications - it allows me to easily add interface support<br>
to any of my existing classes.<br>
<br>
I also believe that you can mix COM and CORBA style interfaces in your<br>
application, but that is probably not a good idea. Best to avoid that.<br>
<br>
<br>
<br>
Regards,<br>
- Graeme -<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal<br>
<a href="http://fpgui.sourceforge.net/" target="_blank">http://fpgui.sourceforge.net/</a><br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</div></div></blockquote></div><br>