Browse thread
[Caml-list] const equivalent for mutable types?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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 ;-)? Cheers, Jon. ------------------- 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