caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andreas Rossberg <rossberg@ps.uni-sb.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] How to downcast in OCAML
Date: Mon, 23 Sep 2002 11:49:25 +0200	[thread overview]
Message-ID: <3D8EE3A5.7C2DFD1D@ps.uni-sb.de> (raw)
In-Reply-To: <20020921173035.00D507F5B@lobus.fungible.com>

Tim Freeman wrote:
> 
> For what it's worth (which may not be much), it is possible to write
> classes in OCAML that are downcastable.  Here's how.
> 
> [trick using exception constructors]

Unfortunately, your scheme does not scale to class hierarchies deeper
than 1. Consider for example adding `subsubclass' as a subclass of
`subclass_1'. Then you might want to downcast from `superclass' to
`subclass_1', but your object actually is a `subsubclass'. Your downcast
will fail. You need hierarchical exception constructors to make that
work.

	- Andreas

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids; I mean if Pac Man affected us
 as kids, we would all be running around in darkened rooms, munching
 magic pills, and listening to repetitive electronic music."
 - Kristian Wilson, Nintendo Inc.
-------------------
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-09-23  9:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-21 15:09 Tim Freeman
2002-09-23  9:49 ` Andreas Rossberg [this message]
2002-09-25  7:10 ` Jean-Christophe Filliatre

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=3D8EE3A5.7C2DFD1D@ps.uni-sb.de \
    --to=rossberg@ps.uni-sb.de \
    --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).