Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
functors vs classes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1997-05-20 (14:34)
From: Francois Rouaix <Francois.Rouaix@i...>
Subject: Re: functors vs classes

> In the caml programming language we are offered an (unprecedented) 
> choice between two varieties of modular polymorphism, classes and 
> functors.  Each offers distinct advantages, and yet in a way it seems 
> that each supports a different _style_ of programming.  In my limited 
> experience it seems that most people opt to focus on functors for 
> their modularization needs, and make little or no use of the 
> objective stuff.  How do others see this? 

A historical note:
Objects are pretty much orthogonal to the rest of the system, and were
only very recently made available in Caml. Functors are a bit older, and
also much more familiar in the ML community.

AFAIK, I use both functors and objects. I find objects most useful when
manipulating a (possibly complex) state through a set of (possibly recursive)
functions. This situation arises very frequently in the kind of code I'm
writing : lots of IO and threads.

Also, I got the impression that functors and inheritance are much more
useful when designing and writing a library than when writing an application.

Mes deux centimes,