Browse thread
What does underscore mean in this type expression?
-
Richard Jones
-
Christophe TROESTLER
-
Richard Jones
-
Christophe TROESTLER
- Richard Jones
-
Christophe TROESTLER
-
Richard Jones
-
Christophe TROESTLER
[
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: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] What does underscore mean in this type expression? |
On Sat, Aug 30, 2008 at 03:57:54PM +0200, Christophe TROESTLER wrote:
> On Sat, 30 Aug 2008 14:03:10 +0100, Richard Jones wrote:
> >
> > > # let x = ref `X;;
> > > val x : _[> `X ] ref = {contents = `X}
> >
> > OK ... so how to get rid of the error? Even supplying a full type for
> > get_domains in the implementation doesn't get rid of it.
> >
> > Here's the code if anyone wishes to try:
> >
> > http://www.annexia.org/tmp/libvirt.mli
> > http://www.annexia.org/tmp/libvirt.ml
> >
> > $ ocamlc -c libvirt.mli
> > $ ocamlc -c libvirt.ml
>
> Here is the crux of your problem
>
> let f = let a = ref 0 in fun (x : [> `R ]) -> x;;
>
> If you hoist [let have_list_all_domains = ref None] outside [let
> get_domains], then it works fine. The type checker could certainly be
> slightly improved [1] there but I do not know how difficult it is.
Yes, that fixed it, thanks.
> [1] And maybe also the compiler: a rough check seem to indicate that
> hiding the variable in the definition of f is slightly slower.
It use this idiom quite a lot to emulate private (static) variables.
Rich.
--
Richard Jones
Red Hat