3 ms·
Because Reason fully supports imperative and OOP style. You don't need to use functional style if you don't want to (of course, aside from using other people's
by yawaramin 9y ago
Because Reason fully supports imperative and OOP style. You don't need to use functional style if you don't want to (of course, aside from using other people's code). Here's some classic OOP:
class animal = {pub speak = "Animal noise";};
class cat = {inherit class animal; pub speak = "Meow!";};
class dog = {inherit class animal; pub speak = "Bark!";};
let speakTwice(animal: animal) = animal#speak ++ ", " ++ animal#speak;
print_endline(speakTwice(new dog)); /* Bark!, Bark! */
- chillee 9y agoI guess it would be remiss to not mention that most Ocaml users shy away from the object oriented side of the language. Not because it's not well done (it is), but because modules work a lot better for many of the uses cases you'd want classes for.
- pjmlp 9y agoYeah, mainly because in most OOP languages, classes/interfaces are just a kind of glorified modules anyway.