Extending
Unlike namespaces, interfaces can be extended by inheritance. The
construct is introduced by the keyword extends
, like so
Note how the type t
remains abstract in WithTenEuro_INTF
and WithFiftyEuro_INTF
.
It is possible to design diamond inheritance, that is, inheriting twice the same base interface, like so:
Here, the abstract type t
was inherited twice from Euro_INTF
. Note
the optional value five_hundred
, distinghished as such by a
question mark: five_hundred?
. This means that a namespace
implementing NewEuro_INTF
can choose not to implement five_hundred
(because it is often counterfeited). The implementation of an
interface can be done as follows:
Note how five_hundred
was indeed implemented, although it was not
mandatory, and how we added twenty
, even it is not found in any of
the inherited signatures.