Classes AND Modules? What's the point?

From: Mark Engelberg (
Date: Mon Nov 01 1999 - 10:01:00 MET

From: "Mark Engelberg" <>
To: <>
Subject: Classes AND Modules? What's the point?
Date: Mon, 1 Nov 1999 01:01:00 -0800

I have spent some time this past week looking at OCaml for the first time.
I have no previous experience with ML, but I do have a pretty good
understanding of functional languages in principle.

The thing that confuses me the most about OCaml is that there is a huge
overlap between the functionality of classes and modules, with a couple of
subtle differences. Classes offer inheritance which is extremely useful,
but modules have a little more typing flexibility, the ability to share
private data among multiple structures in one package, and the ability to
specify compilation units.

The problem is that because modules are slightly more powerful, it appears
that the entire standard library is implemented as modules, not classes,
despite the fact that this is supposed to be Object-oriented Caml! This
doesn't really make sense to me, because it totally hinders your ability to
subclass and extend the default libraries.

This weird coexistence of classes and modules just doesn't make sense to me.
Wouldn't it have made more sense to simply add the concept of inheritance to
modules, rather than define a new "class" construct that supports
inheritance but not all the other features of modules? Or if the focus is
intended to gradually shift in the direction of classes rather than modules,
shouldn't the standard libraries reflect this?

Can someone please explain?


Mark Engelberg

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:28 MET