From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id CD5CBBCAE for ; Sun, 10 Jul 2005 02:20:46 +0200 (CEST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6A0Kh30025866 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sun, 10 Jul 2005 02:20:46 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id AA5A01DEFF; Sun, 10 Jul 2005 10:20:40 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28894-03; Sun, 10 Jul 2005 10:20:40 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 9962A1BAD2; Sun, 10 Jul 2005 10:20:40 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id DE81525B7B3; Sun, 10 Jul 2005 10:20:37 +1000 (EST) Date: Sun, 10 Jul 2005 10:20:37 +1000 From: Pietro Abate To: caml-list@yquem.inria.fr, caml-list@inria.fr Subject: Re: [Caml-list] Object typing Message-ID: <20050710002037.GA8569@pulp.anu.edu.au> Mail-Followup-To: Pietro Abate , caml-list@yquem.inria.fr, caml-list@inria.fr References: <42D063EC.3040900@earthlink.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42D063EC.3040900@earthlink.net> X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at nez-perce with ID 42D069DB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 caml-list:01 bool:01 endline:01 bool:01 endline:01 anu:01 wrote:01 inherit:01 typing:01 restrict:01 hierarchy:01 variant:02 string:03 string:03 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Sat, Jul 09, 2005 at 05:55:24PM -0600, Matthew O'Connor wrote: > I'm at a loss as how to proceed. Any other suggestions or ideas or > better solutions would be greatly appreciated. Thank you. you can try to restrict the polimorphy variant type (and maybe having more than one type to make the hierarchy explicit). hope this helps. :) p type t = [ `Predator | `Entity | `Chicken ];; class type ientity = object method is_a : t -> bool end class entity : ientity = object method is_a = function |`Entity -> true |#t -> false end class predator = object inherit entity as super method is_a = function |`Predator -> true |#t as v -> super#is_a v end let ent = new predator;; print_endline (string_of_bool (ent#is_a `Predator));; (* returns true *) print_endline (string_of_bool (ent#is_a `Entity));; (* returns true *) print_endline (string_of_bool (ent#is_a `Chicken));; (* returns false *) -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html