https://wiki.dlang.org/?title=DIP48&feed=atom&action=historyDIP48 - Revision history2024-03-29T12:04:03ZRevision history for this page on the wikiMediaWiki 1.31.2https://wiki.dlang.org/?title=DIP48&diff=2957&oldid=prevBiotronic: Created page with "{| class="wikitable" !Title: !'''Interface specifications for aggregate types''' |- |DIP: |48 |- |Version: |1 |- |Status: |Draft |- |Created: |2013-09-08 |- |Last Modified: |2..."2013-09-08T18:11:30Z<p>Created page with "{| class="wikitable" !Title: !'''Interface specifications for aggregate types''' |- |DIP: |48 |- |Version: |1 |- |Status: |Draft |- |Created: |2013-09-08 |- |Last Modified: |2..."</p>
<p><b>New page</b></p><div>{| class="wikitable"<br />
!Title:<br />
!'''Interface specifications for aggregate types'''<br />
|-<br />
|DIP:<br />
|48<br />
|-<br />
|Version:<br />
|1<br />
|-<br />
|Status:<br />
|Draft<br />
|-<br />
|Created:<br />
|2013-09-08<br />
|-<br />
|Last Modified:<br />
|2013-09-08<br />
|-<br />
|Author:<br />
|Simen Kjærås<br />
|}<br />
<br />
== Abstract ==<br />
<br />
An interface specification is a complete list of implemented functions of an aggregate type.<br />
<br />
== Rationale ==<br />
<br />
It may at times be hard to get a full overview of the implemented interface of a class, to find which member functions are there and what their exact signatures are. While an interface may put a lower limit on the implemented member functions, additional functions may be implemented willy-nilly.<br />
<br />
This DIP seeks to solve one of the main problems addressed by [[DIP47]], albeit by a different route.<br />
<br />
== Syntax ==<br />
<br />
Interface specifications add an optional section to aggregate types:<br />
<br />
<syntaxhighlight lang="d"><br />
class C {<br />
// Declaration<br />
interface {<br />
this(float)<br />
int foo();<br />
void bar(ref int n);<br />
}<br />
// Definition<br />
this(float f) {<br />
}<br />
int foo() {<br />
return 3;<br />
}<br />
void baz(ref int n) {<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
== Semantics ==<br />
<br />
# Parameter names may be omitted in the declaration, but must otherwise match those in the definition.<br />
# Types, parameter types, attributes, and UDAs in declaration must be present in both locations.<br />
# Default parameter values must be repeated in both locations or not at all.<br />
# It is an error for @safe/@trusted/@system, private/package/public/export access, linkage and storage classes to differ between declaration and definition.<br />
<br />
== Existing Code ==<br />
<br />
Interface specifications will not break any existing code.<br />
<br />
== Copyright ==<br />
This document has been placed in the Public Domain.<br />
<br />
[[Category: DIP]]</div>Biotronic