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 KAA25700; Tue, 15 Jul 2003 10:22:34 +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 KAA00824 for ; Tue, 15 Jul 2003 10:22:33 +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 h6F8MKf12240; Tue, 15 Jul 2003 10:22:20 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA03389; Tue, 15 Jul 2003 10:22:19 +0200 (MET DST) From: Pierre Weis Message-Id: <200307150822.KAA03389@pauillac.inria.fr> Subject: Re: [Caml-list] syntax of private constructors in CVS version In-Reply-To: from Laurent Vibert at "Jul 15, 103 10:02:40 am" To: lvibert@irisa.fr (Laurent Vibert) Date: Tue, 15 Jul 2003 10:22:19 +0200 (MET DST) Cc: skaller@ozemail.com.au, pierre.weis@inria.fr, brogoff@speakeasy.net, caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; pierre:01 weis:01 caml-list:01 variance:01 foo:01 mutated:01 immutable:01 compiler:01 cristal:01 explicitely:01 mutable:01 constructors:01 syntax:02 indirectly:02 module:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > On Sun, 13 Jul 2003, John Max Skaller wrote: > > > Pierre Weis wrote: > > > > > > > Records with mutable fields are permitted. Mutators explicitely exported > > > as functions are allowed, other mutations are forbidden. > > > > So just a question : since mutations are forbidden, would it be safe to > relaxe the variance for mutable field, to allow something like > > type +'a foo = private {mutable it : 'a} No, since the field ``it'' is indeed mutable and can be mutated either directly from within the module implementation, or indirectly via a mutator function that would be exported in the interface. In addition, the compiler has to know that field ``it'' is mutable, so that it can take care of ``it'' fields in pattern matching (the compiler must bind the contents of those field patterns to avoid bus errors in the expression part of the corresponding clause). Euh, if you really want a field to be treated as not mutable, just define it as immutable :) Simple enough, isnt'it ? Best regards, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- 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