This module allow creation of interface types. Every interface type has a set of methods that can be called on it. Every object can be converted at runtime to the interface type, provided that there are procs that implement all interface methods.
Example
# Define interface type Duck type Duck = distinct Interface interfaceMethods Duck: quack(number: int): string # Make implementation of Duck interface # Implementation objects have to inherit from RootRef. type AmericanDuck = ref object of RootObj name: string proc quack(d: AmericanDuck, number: int): string = return "duck " & d.name & " quacks " & $number & " times" let myDuck: AmericanDuck = AmericanDuck(name: name) let myDuckAsInterface: Duck = myDuck.asDuck # or myDuck.asInterface[Duck]
```