++ed by:

2 PAUSE users
1 non-PAUSE user.

Christian Jaeger
and 1 contributors


FP::Abstract::Interface - protocol for an interface



An interface is just a named base type that other types implement. Its purpose is:

1. to be used as a base type to declare a particular behaviour of the new type, and to define what that behaviour entails (currently just a set of method names that are expected to be implemented)

2. to have the defined behaviour (the set of methods) checked at load time of any module that implements the interface, and issue a warning if anything is missing.

3. to allow code to check at runtime whether objects conform to an interface (early dynamic error detection)

Point (2) is implemented by `FP::Struct`: when defining a class via `FP::Struct`, each given parent class is checked for the implementation of a method `fp_interface_method_names` via `can()`. This method, if present, is supposed to ignore arguments and return a list of the names of the set of methods that is required to implement the interface. This method is called once at load time of each module that defines such a class.