From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id TAA03371 for caml-redistribution; Thu, 20 Jun 1996 19:11:11 +0200 Received: (from remy@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id TAA03263; Thu, 20 Jun 1996 19:05:50 +0200 Message-Id: <199606201705.TAA03263@pauillac.inria.fr> Subject: Re: down casting ??? To: Jean-Marie.Favre@imag.fr (FAVRE Jean-Marie) Date: Thu, 20 Jun 1996 19:05:49 +0200 (MET DST) Cc: caml-list@pauillac.inria.fr In-Reply-To: <9606190903.ZM4853@tassili> from "FAVRE Jean-Marie" at Jun 19, 96 09:03:01 am From: Didier.Remy@inria.fr (Didier Remy) Reply-to: Didier.Remy@inria.fr Organization: INRIA, BP 105, F-78153 Le Chesnay Cedex Phone: (33) 1 3963 5317 -- Sec: (33) 1 3963 5684 -- Fax: (33) 1 3963 5330 Web: http://pauillac.inria.fr/~remy MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > 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.