caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: Christophe TROESTLER <Christophe.Troestler+ocaml@umh.ac.be>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] What does underscore mean in this type expression?
Date: Sat, 30 Aug 2008 20:29:36 +0100	[thread overview]
Message-ID: <20080830192936.GB7078@annexia.org> (raw)
In-Reply-To: <20080830.155754.457039520284782231.Christophe.Troestler+ocaml@umh.ac.be>

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


      reply	other threads:[~2008-08-30 19:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30 11:27 Richard Jones
2008-08-30 11:38 ` [Caml-list] " Christophe TROESTLER
2008-08-30 13:03   ` Richard Jones
2008-08-30 13:57     ` Christophe TROESTLER
2008-08-30 19:29       ` Richard Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080830192936.GB7078@annexia.org \
    --to=rich@annexia.org \
    --cc=Christophe.Troestler+ocaml@umh.ac.be \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).