Version française
Home     About     Download     Resources     Contact us    
Browse thread
Immutable cyclic data structures via a
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Francois Pottier <Francois.Pottier@i...>
Subject: Re: [Caml-list] Immutable cyclic data structures via a

On Sat, Dec 13, 2008 at 07:47:46PM -0600, Edgar Friendly wrote:
> ExtLib (and thus batteries) uses your unmute (called [inj]) for
> converting a mutable list into the normal immutable list.  The definition:
> 
> external inj : 'a mut_list -> 'a list = "%identity"
> 
> As always, be *very* careful when using this kind of type system voodoo,
> but it can work under certain circumstances.

This is, in principle, unsound. The compiler could (if it were more agressive)
assume that a value of type 'a list is unaffected by a function call, whereas,
if the list is really mutable, it could actually be written to by the call.

With the current ocaml compiler, this might be okay, but I'd be wary of
building this kind of code into a library.

Best regards,

-- 
François Pottier
Francois.Pottier@inria.fr
http://cristal.inria.fr/~fpottier/