Browse thread
[Caml-list] a design problem requiring downcasting? (long)
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alessandro Baretta <alex@b...> |
| Subject: | Re: [Caml-list] a design problem requiring downcasting? (long) |
Michael Vanier wrote: > > 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! You are very welcome ;) > 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. I don't think there will be any Caml preachers prophesyzing your doom for having desired RTTI. I just have a feeling it does not fit in cleanly with the type system. > It's too bad we can't all roll our own object systems for ocaml ;-) > > Mike Who says you can't? Pick up CamlP4 and write preprocessing code adding your favorite flavor of RTTI to your your classes. You might very well automate the generation of polymorphic-variant-RTTI-tagging object creation functions--my flavor of RTTI--or any other flavor you like best. One might even come up with a syntax extension supporting some form of double-dispatch polymorphism. But, to my great dishonor, I'm still not a CamlP4 guru, so I'll leave this to others. Alex ------------------- 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