Version française
Home     About     Download     Resources     Contact us    
Browse thread
Classes AND Modules? What's the point?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mark Engelberg <mark.engelberg@b...>
Subject: Classes AND Modules? What's the point?
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?

Thanks,

Mark Engelberg