Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 <alex@baretta.com>
> 
> 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
overloading.

> 
> 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
way.  

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

Mike
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners