<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Stewart<div><br><div>An interface in a framework (like COM defined by Microsoft) and a language construct like INTERFACE have no direct relationship.</div><div><br></div><div>If a framework defines an „interface“ (API), it does not necessarily mean the language needs to offer a language construct INTERFACE.</div><div><br></div><div>I could imagine the interface of a framework defines things like</div><div>- mandatory datastructures and hierarchies,</div><div>- the presentation layer (=memory layout) of the data structure (first field is this, second field is this...)</div><div>- mandatory methods/procedures with defined semantics to be implemented on this datastructure</div><div>- If you use COM on Windows, the calls have to follow the Windows calling rules (parameters are passed in registers not via stack)</div><div><br></div><div>As long the language and the compiler can generate the needed rules defined by the framework, we‘re fine off.</div><div><br></div><div>At the moment - without digging into the details - I don‘t see something in the COM framework that couldn‘t be done in Oberon. That said, I agree that some syntax is cumbersome or verbose and could be streamlined to reach the same goal.</div><div>- If the framework for example differentiates 16 bit and 32 bit integers, we would have to do something as the Oberon-07 language only supports one INTEGER type and NW’s compiler maps it to 32 bit.</div><div>- If the framework assumes finalizers (Release method), we can do this in Oberon-07 but the programmer needs more discipline as this is not built-in into the language and has to be programmed explicitely. I agree that a compiler generating these Release calls automatically can help getting rid of memory leaks. With such an adaption, Oberon is no generic programming language any more but very specifically finetuned for COM programming.</div><div>- If the calling rules request fine grained control on register allocation, and the compiler does it differently we have to do something</div><div><br></div><div>br</div><div><div dir="ltr"><div>Jörg</div></div><div dir="ltr"><br><blockquote type="cite">Am 28.10.2020 um 01:12 schrieb Stewart Greenhill <stewart.greenhill@gmail.com>:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>I'm not sure if I caught all of this interesting discussion, but here are a couple of points.</div><div><br></div><div>Interfaces are of course an important mechanism for component software frameworks, such as Microsoft's COM (Component Object Model). COM defines a language-independent binary standard for communication between objects, whether they are in the same process, in different processes on the same machine, or on different machines.</div><div><br></div><div><a href="https://docs.microsoft.com/en-us/windows/win32/com/com-objects-and-interfaces">https://docs.microsoft.com/en-us/windows/win32/com/com-objects-and-interfaces</a><br></div><div><br></div><div>During the 1990s, Oberon Microsystems implemented an extension of the Component Pascal compiler in Blackbox which was called "Direct TO COM" (or "DTC"). This allowed COM components to be written in Component Pascal, and for such components to interact with objects written in any other language.</div><div><br></div><div><a href="https://web.archive.org/web/20040618025116/http://www.oberon.ch/prod/DTC/index.html">https://web.archive.org/web/20040618025116/http://www.oberon.ch/prod/DTC/index.html</a><br></div><div><br></div><div>I can't remember all the details, but one of the important technical issues is that COM interfaces (and therefore the generated Oberon objects) use C++ VTBL object representation. That is, the first element of every object is a pointer to a table of its virtual methods, which is different to the usual layout for Oberon-2 records.</div><div><br></div><div>COM is based on a fairly simple but powerful idea: Every object must implement the interface "IUnknown", and every interface must extend IUnknown. The method IUnknown:QueryInterface allows the client to retrieve other interfaces of the object, which in COM are named using GUIDs ("globally unique identifier). This mechanism allows an object to implement one or more of its own interfaces, or indeed for it to delegate its own interfaces to other objects (eg. via aggregation)</div><div><br></div><div><p style="color:rgb(0,0,0);margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">PROCEDURE (this: IUnknown) QueryInterface (IN [iid] iid: GUID; OUT [new] int: IUnknown): RESULT;</span></p><p style="color:rgb(0,0,0);margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p></div><div>To implement a single interface, you define an object that extends the interface type. To implement multiple interfaces, you would need to define a separate object for each additional interface, which would hold a pointer to the main object and forward any method calls from the interface object to the main object. This could involve some work, but would be fairly simple and could potentially be automated.</div><div><br></div><div>A slightly different implementation is described in "Fine-grained integration of Oberon into Windows using pluggable objects" by Emil Zeller. This includes a quite detailed description of how he integrated Oberon-2 objects into Microsoft's OLE2 compound document model. This includes interfaces for object persistence, display, and interaction. There is also an interface "IDispatch" which allows properties and methods of objects to be enumerated at run-time, so that components can be integrated into scripting environments or visual editors. </div><div><br></div><div><a href="https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/72691/eth-26257-02.pdf">https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/72691/eth-26257-02.pdf</a><br></div><div><br></div><div>I'm not sure much of this is directly useful, but its definitely worth understanding what COM is and how it works. The underlying ideas are fairly simple, and could easily be emulated in a small-scale project.</div><div><br></div><div>Cheers,</div><div> Stewart</div><div><br></div></div></div></div></div></div></div></div></div></div>
<span>--</span><br><span>Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems</span><br><span>https://lists.inf.ethz.ch/mailman/listinfo/oberon</span><br></div></blockquote></div></div></body></html>