Context: I’m reading Classes - Real World OCaml
Question: In Rust, we an do the following:
pub struct Foo { ... }; // defines class Foo
pub trait Some_Trait {
... list a bunch of function signtures ...
}
impl Some_Trait for Foo {
... implement the methods here ...
}
So note, we can separate two things: (1) defining the fields of struct Foo
, and (2) implementing the methods of struct Foo
===
In the OCaml docs I have seen above, it seems all the methods are defined inline where we define the class. Thus, my question:
Are we able to separate the two, i.e.:
(1) define the fields of an OCaml class in one ml file
(2) add some methods to it in another ml file ?
Or, are we required to define all methods of the class at the moment we list the fields of the class ?
Thanks!