caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michael Vanier <mvanier@cs.caltech.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] dynamic runtime cast in Ocaml
Date: Wed, 6 Nov 2002 18:01:26 -0800	[thread overview]
Message-ID: <200211070201.gA721Qm17773@orchestra.cs.caltech.edu> (raw)
In-Reply-To: <20021106135428.A8640@pauillac.inria.fr> (message from Xavier Leroy on Wed, 6 Nov 2002 13:54:28 +0100)


> Date: Wed, 6 Nov 2002 13:54:28 +0100
> From: Xavier Leroy <xavier.leroy@inria.fr>
> 
> > 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


  reply	other threads:[~2002-11-07  7:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-06 11:53 Basile STARYNKEVITCH
2002-11-06 12:54 ` Xavier Leroy
2002-11-07  2:01   ` Michael Vanier [this message]
2002-11-07  8:11     ` Jacques Garrigue
2002-11-07  3:28   ` Walid Taha
2002-11-07  7:22     ` Jacques Garrigue
2002-11-07 14:49       ` Walid Taha
2002-11-08 15:26       ` Alain Frisch
2002-11-11  9:26         ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211070201.gA721Qm17773@orchestra.cs.caltech.edu \
    --to=mvanier@cs.caltech.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).