▲ | manx 3 days ago | |||||||
Sounds like type-classes from haskell/scala? Or is that a different thing? | ||||||||
▲ | geokon 3 days ago | parent | next [-] | |||||||
I'm not familiar with Haskell so it's hard for me to say. A cursory look at the wiki.. I get the impression you'd need to explicitly create a new type class? In a dynamic language you can just "dynamically" extend the record (which is sort of like a "class) with new interfaces without making a new class type. Hopefully that helps.. Sorry if it's not exactly helpful The protocol example at the end shows how it's done https://eli.thegreenplace.net/2016/the-expression-problem-an... If you write something like
Then you are adding (and defining) the Evaluatable interface to a record BinaryPlus (which can be coming from a different library and already be implementing other interfaces)BinaryPlus records can still be used where they were used previously, but you can also use them with the enhancement you added | ||||||||
| ||||||||
▲ | asa400 3 days ago | parent | prev [-] | |||||||
Yep pretty much. It’s “open world” polymorphism. |