Browse thread
[Caml-list] coercions from superclass to subclass?
-
Michael Vanier
- Alessandro Baretta
- Jacques Garrigue
[
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] coercions from superclass to subclass? |
Michael Vanier wrote: > I understand that there is no mechanism to coerce from a superclass to a > subclass in ocaml (i.e. the equivalent of C++'s run-time type > identification or java's instanceof operator). Are there any plans to add > such a capability in the future? > > Mike Jacques Garrigue gave the following explanation a week ago. > By the way, here is a simple way to do downcasts, when > really needed. > > # let tbl : (< >, impl) Hashtbl.t = Hashtbl.create 17 > let register obj = Hashtbl.add tbl (obj :> < >) obj > let recover obj = Hashtbl.find tbl (obj :> < >) ;; > val tbl : (< >, impl) Hashtbl.t = <abstr> > val register : impl -> unit = <fun> > val recover : < .. > -> impl = <fun> ------------------- 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