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 IAA06692; Thu, 7 Nov 2002 08:08:45 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA05937 for caml-list@pauillac.inria.fr; Thu, 7 Nov 2002 08:08:44 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA30082 for ; Thu, 7 Nov 2002 03:01:29 +0100 (MET) Received: from swordfish.cs.caltech.edu (swordfish.cs.caltech.edu [131.215.44.124]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gA721S528844 for ; Thu, 7 Nov 2002 03:01:28 +0100 (MET) Received: from orchestra.cs.caltech.edu (orchestra.cs.caltech.edu [131.215.44.20]) by swordfish.cs.caltech.edu (Postfix) with ESMTP id B2BA6DF26C for ; Wed, 6 Nov 2002 18:01:26 -0800 (PST) Received: (from mvanier@localhost) by orchestra.cs.caltech.edu (8.11.6/8.9.3) id gA721Qm17773; Wed, 6 Nov 2002 18:01:26 -0800 Date: Wed, 6 Nov 2002 18:01:26 -0800 Message-Id: <200211070201.gA721Qm17773@orchestra.cs.caltech.edu> X-Authentication-Warning: orchestra.cs.caltech.edu: mvanier set sender to mvanier@cs.caltech.edu using -f From: Michael Vanier To: caml-list@inria.fr In-reply-to: <20021106135428.A8640@pauillac.inria.fr> (message from Xavier Leroy on Wed, 6 Nov 2002 13:54:28 +0100) Subject: Re: [Caml-list] dynamic runtime cast in Ocaml References: <15817.713.977123.557926@hector.lesours> <20021106135428.A8640@pauillac.inria.fr> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Date: Wed, 6 Nov 2002 13:54:28 +0100 > From: Xavier Leroy > > > I am sometimes lacking the dynamic cast (with a runtime test) in > > Ocaml. Assuming that I have the usual point and colored_point classes > > (as in the 3.06 Manual), I want to deal with point array-s and test if > > the 3rd point is in fact a colored point. > > Is there some type-theoritical issues here? > > There was a long thread on this topic on this list not long ago. > Several approaches were discussed: using datatypes (Point of point | > CPoint of cpoint), extensible datatypes (via the type "exn" of > exceptions), etc. See also Coca-ML: > http://www.pps.jussieu.fr/~emmanuel/Public/Dev/coca-ml/index-en.html > I started that thread, and I concluded at the end of it that all approaches to simulating downcasting in ocaml were, at best, hacks. From there it was a short step to concluding that ocaml was simply not the best choice for my application. This is not to disparage ocaml, which is still my favorite computer language, but sometimes you need something more dynamic. Dynamic is not a dirty word ;-) I understand some of the objections to downcasting, but what I'm really curious about is this: if the ocaml team really *wanted* to allow downcasts (raising an exception on failure just like dividing by zero does), would it be technically feasible? By feasible I mean doable without nasty Obj.magic hacks (no offense to coca-ml, which is very clever). 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