From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 19DEBBB81 for ; Thu, 1 Dec 2005 11:18:12 +0100 (CET) Received: from mail.tcs.inf.tu-dresden.de (tcs01.inf.tu-dresden.de [141.76.75.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB1AIBYN001171 for ; Thu, 1 Dec 2005 11:18:11 +0100 Received: from localhost (localhost [127.0.0.1]) by mail.tcs.inf.tu-dresden.de (Sun Java System Messaging Server 6.1 HotFix 0.06 (built Nov 11 2004)) with ESMTP id <0IQT00M44DYB9900@mail.tcs.inf.tu-dresden.de> for caml-list@yquem.inria.fr; Thu, 01 Dec 2005 11:18:11 +0100 (MET) Received: from tcs01.inf.tu-dresden.de ([127.0.0.1]) by localhost (mail.tcs.inf.tu-dresden.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01106-02 for ; Thu, 01 Dec 2005 11:18:11 +0100 (MET) Received: from ithif59.inf.tu-dresden.de (ithif59.inf.tu-dresden.de [141.76.75.59]) by mail.tcs.inf.tu-dresden.de (Sun Java System Messaging Server 6.1 HotFix 0.06 (built Nov 11 2004)) with ESMTPS id <0IQT00M6XDYB9T00@mail.tcs.inf.tu-dresden.de> for caml-list@yquem.inria.fr; Thu, 01 Dec 2005 11:18:11 +0100 (MET) Received: from tews by ithif59.inf.tu-dresden.de with local (Exim 4.50) id 1EhlVy-0001Xu-WC for caml-list@yquem.inria.fr; Thu, 01 Dec 2005 11:18:11 +0100 Date: Thu, 01 Dec 2005 11:18:10 +0100 From: Hendrik Tews Subject: Re: [Caml-list] printf format strings In-reply-to: To: caml-list@yquem.inria.fr Message-id: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT X-Virus-Scanned: amavisd-new at tcs.inf.tu-dresden.de References: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 X-Miltered: at nez-perce with ID 438ECDE3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; hendrik:01 tews:01 tews:01 caml-list:01 printf:01 fmt:01 fmt:01 toplevel:01 toplevel:01 printf:01 kkkk:01 kkkk:01 sprintf:01 char:01 hendrik:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Jonathan Roewen writes: { fmt %}: convert a format string argument. The argument must have the same type as the internal format string fmt. And how to use it? I get Bad format `%{' in the toplevel. My toplevel accepts it, but does nothing on it: # Printf.printf "%{%d%s%}" "kkkk\n" ;; This expression has type (int -> string -> 'a, 'b, 'c, int -> string -> 'a) format4 but is here used with type (int -> string -> 'a, 'b, 'c, 'a) format4 This is expected, because kkkk has the wrong type. # Printf.printf "%{%d%s%}" "kk%dkk%s\n" ;; - : unit = This should print something I guess. The "unknown constructor" looks very suspicious. Maybe the %{ format is meant to generate random strings??? # String.escaped(Printf.sprintf "%{kkk%}" "kkk\n") ;; - : string = "\\136LÛ\\149*\\000\\000\\000 óY\\149*\\000\\000\\0000\\tî\\149*\\000\\000" ;-) Note that there is a typo in the docs: There is no format %\(...%\): # Printf.printf "%\\(aaa%\\)";; Bad conversion %\, at char number 0 in format string ``%\(aaa%\)'' It is %(...%): # Printf.printf "%(aaa%)";; - : ('_a, '_b, '_c, '_a) format4 -> unit = However, it does not seem to work either: # Printf.printf "%(aaa%)" "bbbb";; - : unit = Bye, Hendrik PS. These two conversions are new, but not marked as such in the enhanced reference manual, because they do not appear in the txt version (which I used for the diffs).