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 JAA06927; Thu, 4 Apr 2002 09:36:41 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA07483 for ; Thu, 4 Apr 2002 09:36:39 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g347adL02922 for ; Thu, 4 Apr 2002 09:36:39 +0200 (MET DST) Received: (from fpottier@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA05873 for caml-list@inria.fr; Thu, 4 Apr 2002 09:36:38 +0200 (MET DST) Date: Thu, 4 Apr 2002 09:36:38 +0200 From: Francois Pottier To: caml-list@inria.fr Subject: Re: [Caml-list] Type variables won't generalize Message-ID: <20020404093638.A23318@pauillac.inria.fr> Reply-To: Francois.Pottier@inria.fr References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 1.0i In-Reply-To: ; from rtarpine@hotmail.com on Wed, Apr 03, 2002 at 08:37:02PM -0500 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Apr 03, 2002 at 08:37:02PM -0500, Ryan Tarpine wrote: > > 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. 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/ ------------------- 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