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 AAA04485; Fri, 19 Apr 2002 00:58:01 +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 AAA04480 for ; Fri, 19 Apr 2002 00:58:00 +0200 (MET DST) Received: from wetware.wetware.com (wetware.wetware.com [199.108.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g3IMvxL14747 for ; Fri, 19 Apr 2002 00:57:59 +0200 (MET DST) Received: from (local broken client) localhost(dh05.wetware.com[199.108.16.45]) (1603 bytes) by wetware.wetware.com via sendmail with P:esmtp/R:bind_hosts/T:inet_zone_bind_smtp (sender: ) id for ; Thu, 18 Apr 2002 15:57:58 -0700 (PDT) (Smail-3.2.0.114 2001-Aug-6 #1 built 2002-Jan-4) Date: Thu, 18 Apr 2002 15:57:59 -0700 Subject: Re: [Caml-list] Is a Cow an Animal? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v481) Cc: The Trade To: Pixel From: james woodyatt In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.481) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thursday, April 18, 2002, at 03:44 PM, Pixel wrote: > > well, i don't really understand the """type 'diet energy = int""" stuff. > but neither is my ocaml's: > > # let carrot = new carrot 2 ;; > # let cow = new cow 10 ;; > # let _ = cow#feed carrot#energy ;; > > # cow#feed;; > - : [ `E_cow] energy -> cow = > # carrot#energy;; > - : [ `E_rabbit | `E_human] energy = 2 > # (carrot#energy : [ `E_cow ] energy);; > - : [ `E_cow] energy = 2 > > what am i missing? It looks like the 'a energy type is not actually abstract in your trial above. It has to be abstract or the technique doesn't work. # carrot#energy;; - : [ `E_rabbit | `E_human] energy = 2 Since the type is concrete, it resolves at compile time into an integer, and an integer is an integer is an integer. Try compiling the .cmo file from the .ml and .mli files I posted and using the #load directive from the top-level. -- j h woodyatt ------------------- 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