Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] syntax of private constructors in CVS version
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-07-15 (08:22)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] syntax of private constructors in CVS version
> 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,,

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: