3 ms·
In OCaml: module Foo = struct let first = 1 let second = 2 let third = 3 end module Bar = struct include Foo (* Include
by andrepd 7y ago
In OCaml:
module Foo = struct
let first = 1
let second = 2
let third = 3
end
module Bar = struct
include Foo (* Include contents of [Foo] *)
let third = 4 (* Override [third] *)
end
- deleted 7y ago[deleted]
- colllectorof 7y agoOCaml has real objects and classes. Moreover, it is trivial to demonstrate that your example doesn't work in practice: module Foo = struct let first() = 1 let second() = first() + 1 end module Bar = struct include Foo let first() = 0 end Bar.second () will still be 2 because of static binding. Thus you cannot use this approach to replace 'first' by itself without creating inconsistencies.