3 ms·
Depends on the language. In Java, you have to explicitly mark a class as conforming to an interface inside the class's declaration. You need to have the source
by nine_k 6y ago
Depends on the language.
In Java, you have to explicitly mark a class as conforming to an interface inside the class's declaration. You need to have the source and modify it.
In Haskell, you mark a type as conforming to an interface (called typeclass) by adding functions that operate on its instances and implement the interface's requirements. You can do it anywhere, and write an implementation for an existing type, which is normal practice.
In Python, you cannot easily add interface conformance, but possibly you can make a trivial subclass of the desired class, and mark it as conforming to the desired interface (Protocol), without modifying the source.
- deleted 6y ago[deleted]