From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 69FBCBC68 for ; Sat, 11 Nov 2006 22:15:53 +0100 (CET) Received: from smtphost.cis.strath.ac.uk (smtphost.cis.strath.ac.uk [130.159.196.96]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kABLFqsW021955 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 11 Nov 2006 22:15:53 +0100 Received: from [10.0.0.17] ([84.13.34.209]) by smtphost.cis.strath.ac.uk (8.13.4/8.13.3/Debian-6) with ESMTP id kABLFiLg004253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 11 Nov 2006 21:15:45 GMT Message-ID: <45563D79.4070207@cis.strath.ac.uk> Date: Sat, 11 Nov 2006 21:15:37 +0000 From: Peter Gregory User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Martin Jambon Cc: Peter Gregory , ermine@ermine.pp.ru, caml-list@inria.fr Subject: Re: [Caml-list] printf and positional specifier References: <20061111201226.GA14282@ermine.home> <4556342C.10109@cis.strath.ac.uk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-CIS-MailScanner: Found to be clean X-CIS-MailScanner-SpamCheck: not spam, SpamAssassin (score=0.007, required 6, autolearn=disabled, AWL 0.01) X-CIS-MailScanner-From: pg@cis.strath.ac.uk X-Miltered: at discorde with ID 45563D88.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; printf:01 specifier:01 ocaml:01 printf:01 fprintf:01 libref:01 specifies:01 wrote:01 wrote:01 char:01 caml-list:01 jambon:01 argument:02 argument:02 caml:02 Martin Jambon wrote: > On Sat, 11 Nov 2006, Peter Gregory wrote: > >> Anastasia Gornostaeva wrote: >>> Hello. >>> >>> $ ocaml >>> Objective Caml version 3.09.3 >>> >>> # open Printf;; >>> # printf "%2$d %1$s" "abc" 2;; >>> Bad conversion %$, at char number 0 in format string ``%2$d %1$s'' >>> >>> >>> How? >>> >>> ermine >>> >> >> Hi Ermine, >> >> I'm not sure that I understand your question. I think to achieve what >> you seem to be trying, you would simply write: >> >> # printf "%d %s" 2 "abc";; >> >> You just put the parameters in the order they came in the string. >> Does that help, it seems like perhaps you needed more than that. > > The dollar stuff is real, although I have no idea of how to make it > work. It's the last paragraph in the description of Printf.fprintf: > http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html > > I take a different reading to you Martin, although I think it is confusing. I believe that the number specified before the dollar sign is the argument that specifies the /precision/ of the output. So, it is not to specify the argument to print, but the argument to use as precision. That said, I tried it in the context they suggest and I couldn't make it work! Ermine: do you have a situation where this is important? I can't think of any situation that comes to mind. Peter.