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 (13:47)
From: Jon Harrop <jon@j...>
Subject: Re: [Caml-list] const equivalent for mutable types?
On Saturday 31 July 2004 11:34, Markus Mottl wrote:
> ...
>   val incr : (int, [> `W ]) t -> unit
>   val decr : (int, [> `W ]) t -> unit

Should these both be [`R|`W]?

> The phantom variable is 'rw.  When creating references, it can be any
> of `R (for reading) and `T (for writing).

Do you mean `W for writing?

That's very interesting. So a phantom type is a type which you stick in to 
dupe the type system into doing something for you? Is there a good reference 
on those? I seem to remember a thread about their utility in porting the STL 
to ocaml but that was before I had ever used OCaml...

And this const-alternative is useful when dealing with large records which 
have mostly constant but some mutable entries because handling such records 
invokes a lot of copying? But, say, arrays are passed by reference so this 
wouldn't provide much of a performance advantage, is that right? 
Incidentally, does anyone have a functional array implementation (which 
doesn't suck ;-)?


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