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] a design problem requiring downcasting? (long)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-09-30 (10:32)
From: Michael Vanier <mvanier@c...>
Subject: Re: [Caml-list] a design problem requiring downcasting? (long)

> Date: Mon, 30 Sep 2002 00:59:29 +0200
> From: Alessandro Baretta <>
> Michael Vanier wrote:
>  > 1) multiple dispatch polymorphism (dispatching on the 
> types of both obj1
>  >    and obj2).  This is the most elegant approach, but 
> almost no languages
>  >    support this (I think because it's very hard to 
> implement efficiently).
> Oh, so what you really need is RTTI, not downcasting, 
> really. I cannot help you here. I think you need method 
> overloading for this one, and I doubt you'll get it soon in 
> O'Caml.

I definitely need RTTI.  I'm not sure why you think I need method

> I'm curious about this, so I would be glad if you let me 
> know what you end up doing.
> Alex

I'm not sure.  All the approaches I've seen in ocaml seem incredibly heavy
compared with RTTI in java (and/or more brittle).  I'm not sure about your
approach, though (it looks pretty light).  Thanks for the suggestion!

Here is a question for the language designers: is there a technical reason
why RTTI can't be done easily in the ocaml object system?  Or is the lack
of RTTI more of a "moral" issue?  Or is it just due to not enough time to
put in all the features one would like?  I can imagine that the fact that
subtyping is implicit for any class that implements the methods of a
superclass might make RTTI very tricky to implement cleanly in a general

It's too bad we can't all roll our own object systems for ocaml ;-)

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