[
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: | 2004-09-22 (01:04) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] Re: OCAML Downcasting? |
On Wed, 2004-09-22 at 08:06, Michael Vanier wrote: > Um, no, they didn't. In fact, it's a completely different mechanism. The > compiler erases the generic information so that the JVM sees only old-style > java classes without parameterization and adds casts where needed. OK, > this wasn't the greatest example in the world, because it relies massively > on RTTI. Ocaml does this too. However, the polymorphism uses *static* type checking to erase the type information, and doesn't need to use RTTI. BTW: Ocaml *does* provide limited RTTI and dynamic dispatch on that RTTI. If you examine: type num = Int of int | Float of float match x with | Int x -> print_int x | Float x -> print_float x you can see that the match must use RTTI and it does. However it isn't a full description of the type, just an integral 'tag' allowing a switch to the correct case. Not enough information to check the type -- the static type system has checked already 'up to which variant' and the rest is done at runtime. Similarly, RTTI is used to do array bounds checks in Ocaml: arrays typing is weaker than in Pascal, which never needs array bound checks, or Modula, where advanced analysis can elide about 60% of such checks. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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