From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA09520 for caml-redistribution@pauillac.inria.fr; Mon, 10 Apr 2000 02:05:16 +0200 (MET DST) Resent-Message-Id: <200004100005.CAA09520@pauillac.inria.fr> 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 CAA24683 for ; Mon, 10 Apr 2000 02:03:09 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id CAA20194; Mon, 10 Apr 2000 02:03:09 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA24498; Mon, 10 Apr 2000 02:03:08 +0200 (MET DST) Message-ID: <20000410020308.18555@pauillac.inria.fr> Date: Mon, 10 Apr 2000 02:03:08 +0200 From: Pierre Weis To: Xavier Leroy Cc: caml-list@inria.fr Subject: Re: cyclic value construction ("let rec") References: <20000406151819.42281@pauillac.inria.fr> <200004061334.PAA18159@miss.wu-wien.ac.at> <20000406162552.49765@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <20000406162552.49765@pauillac.inria.fr>; from Xavier Leroy on Thu, Apr 06, 2000 at 04:25:52PM +0200 Resent-From: weis@pauillac.inria.fr Resent-Date: Mon, 10 Apr 2000 02:05:16 +0200 Resent-To: caml-redistribution@pauillac.inria.fr > > > This certainly suggests to allow the export of an immutable view of a > > > record type with mutable fields. This way you could do the > Alas, it can do a lot of harm. For one thing, you could break type > safety this way, just like with polymorphic references: [...] > So, no, we can't allow exporting a record with different mutability > annotations than in its definition. This is perfectly right, and as always with mutable values, you cannot implement a feature without adding some safeguard conditions. That's why I suggested to export an immutable VIEW of a record type with mutable fields, not simply to export it as an immutable type! I was thinking of something like: type 'a loc = {mutable contents : 'a} as {contents : 'a};; This way the compiler knows everything about the type, the original and ``view'' definitions, so that nothing can be invalidated. The gain is that now, direct assignment as x.contents <- value is forbidden, and values of loc cannot be assigned outside their definition module, if this module carefully avoids to export any assignment function. Evidently, values of type ref should be considered mutable by the compiler, for instance during the constant propagation pass. This view conception of type exportation could also be generalized to hide some other information about a type to export: hide some constructors or labels... -- Pierre Weis INRIA, Projet Cristal, http://pauillac.inria.fr/~weis