Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Didier.Remy@inria.fr (Didier Remy)
To: Jean-Marie.Favre@imag.fr (FAVRE Jean-Marie)
Cc: caml-list@pauillac.inria.fr
Subject: Re: down casting ???
Date: Thu, 20 Jun 1996 19:05:49 +0200 (MET DST)	[thread overview]
Message-ID: <199606201705.TAA03263@pauillac.inria.fr> (raw)
In-Reply-To: <9606190903.ZM4853@tassili> from "FAVRE Jean-Marie" at Jun 19, 96 09:03:01 am


> the :> operator make possible to coerce an expression from a type t1 to a
> super type t (this coercion is safe), but how to go from t to t1 ???
> (ok, a dynamic check is need, this operation can raise an exception)

Yes, the coercion is unsafe and a dynamic check is needed.  As you mention,
this could be implemented with dynamics (values carrying their types) and a
typecase.

> When one use collections of object, this kind of feature is useful. 

Yes, this is a typical  example where such a construction would be
convenient. The  way to solve it now is to declare a data type with one
constructor for each different kind of objet that you want to retreive
from the collection (as you would do in ML without objects). 

> (a kind of typecase construction as it is the case in modula 3).
> is it possible ???

Yes, it is. However, dynamics and typecase complicate the language, its
semantics, and its implementation; so, we preferred not to include them.

    Didier.





  reply	other threads:[~1996-06-20 17:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-19  7:03 FAVRE Jean-Marie
1996-06-20 17:05 ` Didier Remy [this message]
1996-06-20 19:11 ` Jerome Vouillon

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=199606201705.TAA03263@pauillac.inria.fr \
    --to=didier.remy@inria.fr \
    --cc=Jean-Marie.Favre@imag.fr \
    --cc=caml-list@pauillac.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