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] const equivalent for mutable types?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-31 (10:50)
From: Markus Mottl <markus@o...>
Subject: Re: [Caml-list] const equivalent for mutable types?
On Sat, 31 Jul 2004, Jean-Marie Gaillourdert wrote:
> There is a very simple way to do so: Just don't pass the references
> around.

For references this is certainly usually the preferred case, but for
mutable records this would be plain awkward.  You don't always want to
copy all data in a structure to an otherwise equivalent constant record.

Even in the case of references you might have a SE-problem: what do
you do if you suddenly discover that it is necessary to overwrite a
reference in a large function which only used the plain value before?
This might require tons of changes.  If you want to deliberately leave
this option open, just pass the reference with an additional "read-only"
type constraint.


Markus Mottl

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