From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA17666; Thu, 18 Apr 2002 12:19:35 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA17662 for ; Thu, 18 Apr 2002 12:19:35 +0200 (MET DST) Received: from leia.mandrakesoft.com (office.mandrakesoft.com [195.68.114.34]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g3IAJYL01284 for ; Thu, 18 Apr 2002 12:19:34 +0200 (MET DST) Received: by leia.mandrakesoft.com (Postfix, from userid 505) id ADC905B14; Thu, 18 Apr 2002 12:19:28 +0200 (CEST) To: John Max Skaller Cc: caml-list@inria.fr Subject: Re: [Caml-list] Is a Cow an Animal? References: <3CBE2CC8.1030407@ozemail.com.au> From: Pixel Date: 18 Apr 2002 12:19:28 +0200 In-Reply-To: <3CBE2CC8.1030407@ozemail.com.au> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk John Max Skaller writes: [...] > You ask in the title "Is a cow an animal?". The answer is no. well, it depends how you define your animal. It *can* be as seen at http://pauillac.inria.fr/~remy/work/virtual/virtual005.html (written by famous guys :) > Use a variant, give up on classes: [...] > You can do a bit better sometimes, by recognising > some commonality: > > type Animal = { > animal_common:animal_part; > animal_variant:animal_split > } > > type animal_split = Horse of horse | Cow of cow > ... > > so that the horse type only contains features unique > to horses. But you should really forget abstraction, > and just build concrete data structures: its really > just a large in memory database, after all: > you really won't gain much hiding the representation here. well, i don't *want* to give up concrete data structures, I'm just trying to write the thing. I don't care wether if it's abstract or not. Any working solution accepted. http://merd.net/pixel/language-study/various/is-a-cow-an-animal/ocaml.listing uses a variant for the kind (I just changed it, it was a string) I've still kept the class to allow sharing of fields. BUT this solution doesn't allow a stricter checking alike ocaml2.listing or c++2.listing. The reason is that you can't parameter the class with values (like (Vegetable Carrot)) only types. Maybe this is possible with polymorphic variants (?), I'll try... ------------------- 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