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 JAA27854; Mon, 10 Dec 2001 09:13:34 +0100 (MET) 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 JAA28144 for ; Mon, 10 Dec 2001 09:13:33 +0100 (MET) 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 fBA8DVT12841; Mon, 10 Dec 2001 09:13:31 +0100 (MET) Received: (from fpottier@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA27917; Mon, 10 Dec 2001 09:13:31 +0100 (MET) Date: Mon, 10 Dec 2001 09:13:31 +0100 From: Francois Pottier To: Ohad Rodeh Cc: caml-list@inria.fr Subject: Re: [Caml-list] mutability analysis too strict? Message-ID: <20011210091331.B2025@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 ORODEH@il.ibm.com on Sun, Dec 09, 2001 at 05:43:41PM +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, Dec 09, 2001 at 05:43:41PM +0200, Ohad Rodeh wrote: > > let h = Hashtbl.create 10;; > h : ('_a, '_b) Hashtbl.t > > The objects and keys in the table are infered to be mutable. However, > in my case, they are immutable and I have to coerce them using Obj.magic > from '_b to 'b. You are slightly wrong here: the analysis infers the table itself (not the keys or objects in it) to be mutable, which it indeed is. If the table was given a polymorphic type, you would be able to store objects of a certain type and to retrieve them at another type (by taking different instances of 'b), which would be unsound. Furthermore, I'm surprised to hear that using Obj.magic helps; indeed, any application of Obj.magic is itself deemed `dangerous' by O'Caml, leading to the following behavior: # let h = Hashtbl.create 10;; val h : ('_a, '_b) Hashtbl.t = # let h = (Obj.magic h : ('a, 'b) Hashtbl.t);; val h : ('_a, '_b) Hashtbl.t = That is, Obj.magic doesn't help at all in this case. Perhaps you could tell us what you are trying to achieve? Any polymorphic, mutable structure is unsound and rightly rejected. A monomorphic, mutable structure that contains polymorphic data is sound, but cannot be expressed in ML's type system where universal quantification must be prenex. -- François Pottier Francois.Pottier@inria.fr http://pauillac.inria.fr/~fpottier/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr