|
|
|
|
|
by d3nj4l
1719 days ago
|
|
While it is true that OCaml does support a kind of OOP, even the OCaml manual outright states that it isn’t used much: https://ocaml.org/manual/objectexamples.html I think the biggest use for objects is to have a kind of row polymorphism? I don’t know too much because I haven’t used them at all. |
|
The biggest quirk coming from something like Java or C# is that you can't downcast. But classes can still opt into this ability (by using virtual methods + extensible variants) where it makes sense; and in most cases, the presence of downcasts means that a discriminated union is probably a better fit to model something than a class.