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
[Caml-list] polymorphic methods
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-07-15 (02:17)
From: Brian Smith <brian-l-smith@u...>
Subject: Re: [Caml-list] polymorphic methods
Jacques Garrigue wrote:
> Sorry, but there is no handling of instanciation via subtyping.
> Currently subtyping and instanciation are orthogonal concepts: you
> cannot subtype in an .mli, and you cannot instanciate an
> explicitly polymorphic type when subtyping.
> I believe it's correct, but you won't make me write the code without a
> proof :-)

That is really an interesting comment. I wonder, what are people 
currently researching w.r.t. the object-oriented features of O'Caml? 
Besides the above, Jacques said that recursive types with classes is not 
completely defined because (paraphrasing) recursive types are 
polymorphic and recursive classes are monomorphic:

     type variant = Node of node
     class node =
         method as_variant : variant = Node self

I wonder, does a similar problem apply to recursive exceptions and classes?:

     (* email me for a complete example *)
     exception NotFound of node
     class node  =
         method find x = ... else raise (NotFound self)

And, similarly, it does seem odd that currently it is impossible to 
create a polymorphic method equivalent to "map" (This type of problem is 
mentioned in

Besides polymorphism, I wonder if it is possible to add open classes and 
multiple dispatch to O'Caml like MultiJava does for Java 

I'm just a beginner and I don't know any of the theory of this yet, so 
i'm hoping somebody else will give Jacques some proofs of solutions to 
the above :)


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: