Skip to content

Mention relation of interfaces to member fields #3104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
20 changes: 17 additions & 3 deletions spec/interface.dd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ $(SPEC_S Interfaces,

$(HEADERNAV_TOC)

$(P An $(I Interface) describes a list of functions that a class which inherits
from the interface must implement.)
$(P An $(I Interface) abstracts from common behaviour in terms of an abstract class
which doesn't expose implementation details of methods and object state.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the previous sentence should probably be joined together. The "it's" is a bit jarring.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: "An Interface abstracts from behaviour in terms of an abstract class which ..."

I originally intended to use simple English but less text is surely reasonable as long as it's comprehensible.

If you have write access to this PR, you are welcome to do the change. I can do this only later on another device.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxhaton I integrated your changes with my ones.

Classes which inherit from an interface must implement the functions signatures.)

$(GRAMMAR
$(GNAME InterfaceDeclaration):
Expand Down Expand Up @@ -39,7 +40,7 @@ $(GNAME BaseInterfaceList):
to that interface.)

$(P Interfaces cannot derive from classes; only from other interfaces.
Classes cannot derive from an interface multiple times.
Classes cannot derive from the same interface multiple times.
)

------
Expand Down Expand Up @@ -78,6 +79,19 @@ interface D
static void foo() { } // ok
final void abc() { } // ok
}
------

$(P Non-static member fields may not be defined in interfaces.
)

------
interface D
{
static immutable e = 2.71828f; // ok
float f; // error, variable `f` field not allowed in interface
immutable g = 3.81f; // error, variable `g` field not allowed in interface
enum h = 6.626f; // ok, compile-time-static symbols are considered static
}
------

$(P Interfaces can have function templates in the members.
Expand Down