Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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.

Regards,
Markus

-- 
Markus Mottl          http://www.oefai.at/~markus          markus@oefai.at

-------------------
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