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 DAA17289; Thu, 4 Apr 2002 03:37:06 +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 DAA20423 for ; Thu, 4 Apr 2002 03:37:05 +0200 (MET DST) Received: from hotmail.com (f268.law8.hotmail.com [216.33.240.143]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g341b3D03307 for ; Thu, 4 Apr 2002 03:37:03 +0200 (MET DST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 3 Apr 2002 17:37:02 -0800 Received: from 68.82.49.153 by lw8fd.law8.hotmail.msn.com with HTTP; Thu, 04 Apr 2002 01:37:02 GMT X-Originating-IP: [68.82.49.153] From: "Ryan Tarpine" To: caml-list@inria.fr Subject: Re: [Caml-list] Type variables won't generalize Date: Wed, 03 Apr 2002 20:37:02 -0500 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 04 Apr 2002 01:37:02.0800 (UTC) FILETIME=[38780500:01C1DB79] Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >From: Charles Martin >To: "Ryan Tarpine" >Subject: Re: [Caml-list] Type variables won't generalize >Date: Wed, 03 Apr 2002 15:19:25 -0800 > > >I'm sure there's a real answer to your question, but in cases like you >describe, I always create the records and then assign back into them. >Thus: > >... > >Also, maybe you want to use mutable fields instead of ref? > >Charles > Using the ref was a silly mistake, yes; that's what I get from moving from a single ref to a tuple of refs to a record for storing data as my program grew in complexity :) But, I'm guessing you did not run the code you suggested. Ocamlc chokes on it in the same manner as my original code. Here's exactly what I just tried: type 'a my_object = { mutable partner : 'a my_object; mutable data : 'a };; let object1 = { partner = Obj.magic 0; data = `PNone };; let object2 = { partner = Obj.magic 0; data = `PNone };; Without even assigning back (it makes no difference whether I do or not), I get the same error: File "foo.ml", line 6, characters 14-58: The type of this expression, _[> `PNone] my_object, contains type variables that cannot be generalized The polymorphic variant is conflicting somehow, and I don't know enough about the type system to figure out how to fix it. I would like to keep the variant because I don't know what types of data will be stored in that field, and I don't want to restrict it to a certain set. I would like modules in the future to be able to store different types without having to recompile the whole program. Ryan Tarpine, rtarpine@hotmail.com "To err is human, to compute divine. Trust your computer but not its programmer." - Morris Kingston Ryan Tarpine, rtarpine@hotmail.com "To err is human, to compute divine. Trust your computer but not its programmer." - Morris Kingston _________________________________________________________________ Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com ------------------- 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