Trying to get familiar with Monkey2. I’ve been looking around but have not been able to find a good clear explanation of what Interfaces are and what they could potentially be used for. The documentation doesn’t really say much about them
Interfaces are used in situations where you might want to simulate what multiple inheritance normally offers in a limited way. By specifying that a class conforms to an interface (classes can conform to multiple interfaces), then you can specify elsewhere that something takes an interface type and normally unrelated classes can use it.
This is useful when you want to create modular systems (like for example, a standard library) since interfaces decouple the definition from the implementation. Without interfaces, a lot more care and foresight must be taken in the design of a set of classes because a change to the implementation sometimes ends up needing a change in the definitions to remain straightforward.
A good example of the use of interfaces is when implementing containers. Another is for the sorting of containers — mx2 uses function calls for this, but .NET languages use generic interfaces to assume a safe definition of what the potential sorting and collating operations are for any particular implementation.
Hoping that generic interfaces are implemented eventually, since their initial absence in monkeyX affected the design of a few base libraries from some users…
You must be logged in to reply to this topic.
Monkey2 is an easy to use, cross platform, games oriented programming language from Blitz Research.