From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA31045; Wed, 22 Sep 2004 03:04:56 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA02322 for ; Wed, 22 Sep 2004 03:04:55 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8M14r0m015936 for ; Wed, 22 Sep 2004 03:04:54 +0200 Received: from [192.168.1.200] (ppp202-133.lns1.syd3.internode.on.net [203.122.202.133]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i8M14cOU015517 for ; Wed, 22 Sep 2004 10:34:48 +0930 (CST) Subject: Re: [Caml-list] Re: OCAML Downcasting? From: skaller Reply-To: skaller@users.sourceforge.net To: caml-list In-Reply-To: <20040921220621.92EA99BD95@orchestra.cs.caltech.edu> References: <20040921220621.92EA99BD95@orchestra.cs.caltech.edu> Content-Type: text/plain Message-Id: <1095815077.2580.935.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 22 Sep 2004 11:04:38 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4150CFB5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 downcasting:01 sourceforge:01 2004:99 vanier:01 generic:01 casts:01 'up:99 runtime:01 elide:01 9660:01 glebe:01 arrays:01 compiler:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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