English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: Real excellent object oriented source code examples of Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-11-21 (17:03)
From: Brian Rogoff <bpr@b...>
Subject: Re: Real excellent object oriented source code examples of Ocaml
On Mon, 20 Nov 2000, David McClain wrote:
> ... in response to Xavier...
> But as someone who learned to appreciate what CLOS had to offer over the
> conventional Smalltalk style of OO, and as an avid user of OCaml, I have to
> say that I really miss CLOS sometimes...

I'm guessing that what you miss is multiple dispatch, right? That is 
the distinguishing feature of CLOS with respect to Smalltalk. I hope you
aren't talking about the CLOS MOP since I think that would play havoc with 
static typing. 

I certainly agree that multiple dispatch has advantages, and some of my
own OO Ocaml code relies on uses of the Visitor pattern, which is obviated 
by the presence of multiple dispatch. If I understood the paper correctly, 
the "extensional polymorphism" approach which has been discussed here for 
adding overloading and safe value IO has some similarities with CLOS 
generic functions but I don't know how it interacts with the object system 
or polymorphic variants. Maybe Jun or Pierre will comment on this. 

With regards to the original poster's query, you may wish to direct your
colleague to Didier Remy's APPSEM notes, which discuss the object system 
of Ocaml in detail. If he or you wish to post questions of the form "how
to do this with Ocaml objects" here I'm sure someone will help. I know I 
had a tough time initially working around the lack of downcasting and type 
querying from Java and C++, but now that I'm a little more proficient I'm
convinced that the designers were right not to include them. If the
designers wish to improve the current OO system, rather than C++ I'd 
look to Eiffel for ideas, in particular Eiffel's renaming capabilities. 
Of course, there is also the (temporary I hope!) lack of polymorphic
methods, which correspond to C++ member template functions...

Here's the URL for the APPSEM notes: 

It is true that OO features are less needed in a language like Ocaml, but
I for one am sure glad they are there. 

-- Brian