<div dir="ltr"><div>A key feature of protocols / interfaces is the safe multiple inheritance: you can explicitly or implicitly (like in the Go language) implement several interfaces and be type compatible with each one of them.<br></div><div><br></div><div>Do you support something like the following?<br></div><div><span style="font-family:monospace"><br></span></div><div><font size="4"><span style="font-family:monospace">TextDesc = RECORD (TextProtocol.TextDesc, WriteProtocol.WriterDesc) END ;  (*this means: “implements TextProtocol.TextDesc AND WriteProtocol.WriterDesc "*)</span></font></div><div><br></div><div>If this is not supported I don't see this feature being that useful. To support the feature above the implementation is more complicated than Oberon-2's bound procedures. See <a href="https://research.swtch.com/interfaces">https://research.swtch.com/interfaces</a> for one way of doing this, or<a href="http://www.academia.edu/download/42084165/Efficient_Implementation_of_Java_Interfa20160204-28309-28q4h3.pdf"> "Efficient implementation of Java interfaces: Invokeinterface considered harmless" </a><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 25, 2020 at 6:46 AM Andreas Pirklbauer <<a href="mailto:andreas_pirklbauer@yahoo.com">andreas_pirklbauer@yahoo.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Correction: In Text1, it’s TextDesc = RECORD (TextProtocol.TextDesc) of course<br>
<br>
—————————<br>
<br>
Protocols (sometimes called interfaces) can be added to<br>
Oberon-2 without adding any keywords to the language.<br>
<br>
This is one of the key differences to how it is usually defined<br>
and implemented, e.g. in Swift [*] or in Integrated Oberon [**]<br>
<br>
Under the new minimalistic design, what distinguishes a protocol<br>
from an actual implementation (of the class) is that in the protocol<br>
definition the implementations of the class methods are simply not<br>
defined. Instead, any module that *imports* a protocol definition<br>
can “adopt” (i.e. implement) it. See the example below.<br>
<br>
An experimental implementation showed that if the language<br>
is extended in *this* way, the implementation cost is minimal.<br>
<br>
But the question is: Is it worth it? Simplicity of implementation<br>
should of course not be a criteria for adopting a new feature.<br>
<br>
Personally, I am rather sceptical of the usefulness of protocols.<br>
But perhaps someone provides a good reason to adopt them.<br>
<br>
-ap<br>
<br>
<br>
Example:<br>
<br>
  MODULE TextProtocol;  (*protocol definition*)<br>
    TYPE Text = POINTER TO TextDesc;<br>
      TextDesc = RECORD data*: (*text data*) END ;<br>
      PROCEDURE (t: Text) Insert (string: ARRAY OF CHAR; pos: LONGINT);<br>
      PROCEDURE (t: Text) Delete (from, to: LONGINT);<br>
      PROCEDURE (t: Text) Length (): LONGINT;<br>
  END TextProtocol;<br>
<br>
  MODULE Text1; (*one implementation of the Text protocol*)<br>
    IMPORT TextProtocol;<br>
    TYPE Text = POINTER TO TextDesc;<br>
      TextDesc = RECORD (TextProtocol.TextDesc) END ;  (*this means: “implements TextProtocol.TextDesc"*)<br>
<br>
    PROCEDURE (t: Text) Insert (string: ARRAY OF CHAR; pos: LONGINT);<br>
    BEGIN (*implementation of Insert*)<br>
    END Insert;<br>
<br>
    PROCEDURE (t: Text) Delete (from, to: LONGINT);<br>
    BEGIN (*implementation of Delete*)<br>
    END Delete;<br>
<br>
    PROCEDURE (t: Text) Length (): LONGINT;<br>
    BEGIN (*implementation of Length*)<br>
    END Insert;<br>
  END Text1;<br>
<br>
<br>
  MODULE Text2; (*another implementation of the Text protocol*)<br>
    IMPORT TextProtocol;<br>
    TYPE Text = POINTER TO TextDesc;<br>
      TextDesc = RECORD (TextProtocol.TextDesc) END ;  (*this means: “implements TextProtocol.TextDesc"*)<br>
<br>
    PROCEDURE (t: Text) Insert (string: ARRAY OF CHAR; pos: LONGINT);<br>
    BEGIN (*implementation of Insert*)<br>
    END Insert;<br>
<br>
    PROCEDURE (t: Text) Delete (from, to: LONGINT);<br>
    BEGIN (*implementation of Delete*)<br>
    END Delete;<br>
<br>
    PROCEDURE (t: Text) Length (): LONGINT;<br>
    BEGIN (*implementation of Length*)<br>
    END Insert;<br>
  END Text2;<br>
<br>
<br>
[*] <a href="https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#" rel="noreferrer" target="_blank">https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#</a><br>
[**] <a href="https://github.com/io-core/technotes/blob/main/technote014.md" rel="noreferrer" target="_blank">https://github.com/io-core/technotes/blob/main/technote014.md</a><br>
<br>
--<br>
<a href="mailto:Oberon@lists.inf.ethz.ch" target="_blank">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br>
<a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" rel="noreferrer" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/oberon</a><br>
</blockquote></div>