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
Re: Overloading again (Was Re: [Caml-list] Interfacing C++ and Ocaml)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-04-01 (20:14)
From: Sven LUTHER <luther@d...>
Subject: Re: Overloading again (Was Re: [Caml-list] Interfacing C++ and Ocaml)
On Fri, Mar 30, 2001 at 12:41:43PM -0800, Hao-yang Wang wrote:
> >An even longer time ago I asked about overloading and got a nice long
> >reply from Francois Rouaix, describing the history of overloading in Caml
> >and ending with something like "Jun Furuse is now working on it". You can
> >read about the latest incarnation of his work by going to 
> >
> >
> >
> >and downloading 
> >
> >Generic Polymorphism in ML
> >
> >which as you can guess is in English unlike his paper last year. 
> >
> >I'd also love to know if and when this will make it into Ocaml since this
> >is one of the few things that I dislike about ML style languages and
> >even after quite a bit of Caml programming I still miss overloading. 
> >
> >-- Brian
> Well, I re-read Francois Rouaix's long email, and at the end he said:
> >In this type system, we still have static type-checking and inference,
> >but there are some practical problems: coherence (as always when you do
> >powerful overloading), true separate compilation, but more significantly,
> >you have to define all "instances" of an overloaded function in a single
> >"generic" definition. In most cases, this is not what the user wants.
> >From Jun Furuse's paper, it seems that we still have to define all 
> "instances" of an overloaded function in a single generic" definition. If 
> so, we cannot extend an existing function/operator, such as (+), to 
> parameters of new types.

Could not some trick like the exception type be used, or maybe the polymorphic
variant ?

somethning like :

let f1 = function
  | 'A x -> xxx
  | 'B x,y -> xx

and later : 

let f1 = function
  | 'C x,y,z -> xxx
  | x -> f1 x

enrobed with some nice syntaxic sugar ?


Sven Luther
To unsubscribe, mail  Archives: