From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C5C9CBC29 for ; Tue, 29 Aug 2006 20:13:15 +0200 (CEST) Received: from smtp-roam.Stanford.EDU (smtp-roam.Stanford.EDU [171.64.10.152]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k7TIDEFk015768 for ; Tue, 29 Aug 2006 20:13:15 +0200 Received: from [192.168.1.10] (rescomp-04-35677.Stanford.EDU [128.12.177.67]) (authenticated bits=0) by smtp-roam.Stanford.EDU (8.12.11/8.12.11) with ESMTP id k7TIDB5t016030 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); Tue, 29 Aug 2006 11:13:11 -0700 In-Reply-To: <1156853008.21883.84.camel@localhost.localdomain> References: <53c655920608250051x48d81cbagabf8039f0269beee@mail.gmail.com> <1156505490.20759.354.camel@rosella.wigram> <1156853008.21883.84.camel@localhost.localdomain> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <39D25033-09DF-4051-81F8-A99CD407A265@cs.stanford.edu> Cc: Ocaml Content-Transfer-Encoding: 7bit From: Ted Kremenek Subject: Re: [Caml-list] Class/prototype-based OO Date: Tue, 29 Aug 2006 11:13:08 -0700 To: Gerd Stolpmann X-Mailer: Apple Mail (2.752.2) X-Miltered: at concorde with ID 44F483BA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; gerd:01 stolpmann:01 home-made:01 rtti:01 foo:01 foo:01 failwith:01 downcasts:01 2006,:98 wrote:01 polymorphic:01 caml-list:01 exception:01 exceptions:01 monomorphic:01 On Aug 29, 2006, at 5:03 AM, Gerd Stolpmann wrote: > Certainly not this way. Simply use exceptions for home-made RTTI: > > class type foo = ... > > exception Foo of foo > > class foo_class : foo = > object(self) > ... > method downcast = raise(Foo(self : #foo :> foo)) > end > > > let downcast_foo (obj : < downcast : unit; ..>) = > try obj # downcast > with Foo x -> x > | _ -> failwith "This is not a foo!" > > > Although this is restricted to monomorphic types please note that the > other languages you mention only have this sort of types. This is a cute idea. I'm glad that you mentioned the point about monomorphic types. Hypothetically, is there any need for "polymorphic" downcasts?