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 OAA02809; Thu, 4 Apr 2002 14:19:36 +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 OAA00303 for ; Thu, 4 Apr 2002 14:19:35 +0200 (MET DST) Received: from hotmail.com (f194.law8.hotmail.com [216.33.241.194]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g34CJYD15590 for ; Thu, 4 Apr 2002 14:19:34 +0200 (MET DST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 4 Apr 2002 04:19:33 -0800 Received: from 68.82.49.153 by lw8fd.law8.hotmail.msn.com with HTTP; Thu, 04 Apr 2002 12:19:31 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: Thu, 04 Apr 2002 07:19:31 -0500 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 04 Apr 2002 12:19:33.0045 (UTC) FILETIME=[FA349650:01C1DBD2] Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >From: Francois Pottier >Reply-To: Francois.Pottier@inria.fr >To: caml-list@inria.fr >Subject: Re: [Caml-list] Type variables won't generalize >Date: Thu, 4 Apr 2002 09:36:38 +0200 > >... > >That is precisely what you cannot do. If different modules were allowed to >store different types into that field, type conflicts could occur. (Imagine >one module chooses to write `A of int, and some other module attempts to >read `A of int -> int. An integer would be cast into a function, leading to >a crash.) In other words, to preserve separate compilation, the compiler >forces you to restrict that variant to a certain set by declaring its type. >The problem does not arise in the toplevel evaluator (ocaml) because it >does >not perform separate compilation. > >-- >François Pottier >Francois.Pottier@inria.fr >http://pauillac.inria.fr/~fpottier/ >------------------- Thank you; that was the explanation I was waiting for! My next question is whether or not there is some non-typesafe route around this. Could I use Obj.magic to store different data types in one field, as long as I keep track of what type is really there (e.g., have a second field that would store a number representing the type) so I can cast back later? Sorry if I keep finding myself longing for the "void*" C-ism! TIA, Ryan Tarpine, rtarpine@hotmail.com "To err is human, to compute divine. Trust your computer but not its programmer." - Morris Kingston _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. ------------------- 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