From: Samuel Hornus <samuel.hornus@inria.fr>
To: Gabriel Cardoso <gcardoso.w@gmail.com>
Subject: Re: [Caml-list] Problem with Arg.Tuple
Date: Tue, 13 Mar 2012 12:21:12 +0100 [thread overview]
Message-ID: <CB3DD35B-AFFA-47BF-BC95-F2C02F97CD1C@inria.fr> (raw)
In-Reply-To: <CADSDpiofjUCP_K3n6XHqHR02UcXCLooKNgsG6fKsqEvyZUfJsg@mail.gmail.com>
On Mar13, 2012, at 11:49 , Gabriel Cardoso wrote:
> Dear list,
>
> I have empty arguments when using Arg.Tuple with references. This minimalist example illustrates my problem :
>
> let f a b =
> print_endline a;
> print_endline b
>
> let s = ref ""
>
> let speclist = [(
> "-a",
> Arg.Tuple [
> Arg.Set_string s;
> Arg.String (f !s) (* !s is empty !!! *)
Here, the value of !s is empty when the (f !s) is evaluated…
you shoud pass the whole reference as argument :
Arg.String(f s)
and
let f a b = print_endline !a; print_endline b
> (* Arg.String (fun ss -> f !s ss) (\* Works just fine ... why ? *\) *)
why ? because the !s is evaluated only later, when the anonymous function (fun ss ->…) is applied.
--
Sam
next prev parent reply other threads:[~2012-03-13 11:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-13 10:49 Gabriel Cardoso
2012-03-13 11:21 ` Samuel Hornus [this message]
[not found] ` <070E17B9-F989-4184-A702-7D323710F52B@inria.fr>
2012-03-13 12:23 ` Gabriel Cardoso
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=CB3DD35B-AFFA-47BF-BC95-F2C02F97CD1C@inria.fr \
--to=samuel.hornus@inria.fr \
--cc=gcardoso.w@gmail.com \
/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