From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q2DCOPJj021686 for ; Tue, 13 Mar 2012 13:24:25 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At4BAPk7X0/RVdm2mWdsb2JhbABDtVgIIgEBAQEBCAsLBxQnggkBAQEDARICExkBGx0BAwELBgUEAQYNLiIBEQEFARwGEyKHYwWfLQqLeIJxhS0/iHQBBQuQWgSVT45FPYQH X-IronPort-AV: E=Sophos;i="4.73,575,1325458800"; d="scan'208";a="149074466" Received: from mail-lb0-f182.google.com ([209.85.217.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 13 Mar 2012 13:24:24 +0100 Received: by lboi15 with SMTP id i15so395964lbo.27 for ; Tue, 13 Mar 2012 05:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=K2JPLnZgXO3z4ijZpSg/2CVU+Gav274R9eSVfDtHBO0=; b=vcQbKRsFAeWniVqzVzlK8FLb1JyVisjgJH72XEkFXD4k4sI7Wzjs2iZjonLnFkGEal jhGj5UQABL4A72qklcna7edPBfIOer/TmYF6ceBZfueoghcEUbLxDqECVyWsqV9QZ8fN DM94c+zDMml72env8qsNb3w3RYdtlAGA+7b9pBb1ZYTjRKl76cTY7yH6EjybegYE0aDb l3RyItjqD9O4INtDzM2UTmGHydIUhLP+oX/buRCogo8h2mPLsI9yLEEaH7/UON5V8kbT vDPZAfgCj92oKhEeZDW9+haNVmZI4puFjfX1CNSeH4NdWrPkrF1JnsjoCmEdbL9UJr41 lJTw== Received: by 10.152.128.38 with SMTP id nl6mr12037106lab.15.1331641463912; Tue, 13 Mar 2012 05:24:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.25.73 with HTTP; Tue, 13 Mar 2012 05:23:52 -0700 (PDT) In-Reply-To: <070E17B9-F989-4184-A702-7D323710F52B@inria.fr> References: <070E17B9-F989-4184-A702-7D323710F52B@inria.fr> From: Gabriel Cardoso Date: Tue, 13 Mar 2012 13:23:52 +0100 Message-ID: To: Samuel Hornus Cc: caml-list Content-Type: multipart/alternative; boundary=f46d043086c06cb97d04bb1ef0f8 Subject: Re: [Caml-list] Problem with Arg.Tuple --f46d043086c06cb97d04bb1ef0f8 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Thanks, I get it now ! Cheers Gabriel 2012/3/13 Samuel Hornus > > 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 =3D > > print_endline a; > > print_endline b > > > > let s =3D ref "" > > > > let speclist =3D [( > > "-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=85 > you shoud pass the whole reference as argument : > Arg.String(f s) > and > let f a b =3D print_endline !a; print_endline b > > > (* Arg.String (fun ss -> f !s ss) (\* Works just fine ... why ? *\) > *) > > why ? because the !s here is evaluated only later, whenthe anonymous > function is applied. > -- > Sam --f46d043086c06cb97d04bb1ef0f8 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Thanks, I get it now !

Cheers

G= abriel

2012/3/13 Samuel Hornus <samuel.hornus@= inria.fr>

On Mar13, 2012, at 11:49 , Gabriel Cardoso wrote:

> Dear list,
>
> I have empty arguments when using Arg.Tuple with references. This mini= malist example illustrates my problem :
>
> let f a b =3D
> =A0 print_endline a;
> =A0 print_endline b
>
> let s =3D ref ""
>
> let speclist =3D [(
> =A0 "-a",
> =A0 Arg.Tuple [
> =A0 =A0 Arg.Set_string s;
> =A0 =A0 Arg.String (f !s) (* !s is empty !!! *)

Here, the value of !s is empty when the (f !s) is evaluated=85
you shoud pass the whole reference as argument :
Arg.String(f s)
and
let f a b =3D print_endline !a; print_endline b

> =A0 =A0 (* Arg.String (fun ss -> f !s ss) (\* Works just fine ... w= hy ? *\) *)

why ? because the !s here is evaluated only later, whenthe anonymous = function is applied.
--
Sam

--f46d043086c06cb97d04bb1ef0f8--