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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 63927BB81 for ; Thu, 1 Dec 2005 17:26:32 +0100 (CET) Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.199]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jB1GQVh9031491 for ; Thu, 1 Dec 2005 17:26:31 +0100 Received: by nproxy.gmail.com with SMTP id o25so95238nfa for ; Thu, 01 Dec 2005 08:26:31 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=VefeMZFySN/KbcT5y32nr4Px6z9xCknqq5/+plE8n4dSEmV/3lPrR519+KhpFv95uHJqyfsbmbXYv9ziWNpjPuxNpWb6Frtt0RIYlIUxMRp6PRKt2HUFJOJ+rG2F7Tc3BZ5pHPJaz9qpag5IgNZLjB9mV6epjFBAEMS5QxchFMw= Received: by 10.48.210.10 with SMTP id i10mr323550nfg; Thu, 01 Dec 2005 08:26:31 -0800 (PST) Received: by 10.48.42.14 with HTTP; Thu, 1 Dec 2005 08:26:31 -0800 (PST) Message-ID: <6b8a91420512010826t540e0308v@mail.gmail.com> Date: Thu, 1 Dec 2005 17:26:31 +0100 From: Remi Vanicat To: caml-list@yquem.inria.fr Subject: [Caml-list] printf format strings In-Reply-To: <6b8a91420512010825k23d78780u@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <6b8a91420512010825k23d78780u@mail.gmail.com> X-Miltered: at concorde with ID 438F2437.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 hendrik:01 tews:01 tews:01 fmt:01 fmt:01 toplevel:01 toplevel:01 printf:01 kkkk:01 kkkk:01 bug:01 bool:01 bool: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=RCVD_BY_IP autolearn=disabled version=3.0.3 005/12/1, Hendrik Tews : > 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 =3D > > This should print something I guess. The "unknown constructor" > looks very suspicious. Maybe the %{ format is meant to generate > random strings??? Well, I've guessed a bug in the type system, and it seem I'm correct: let t =3D Obj.repr (Printf.printf "%{%d%s%}" "kk%dkk%s\n");; # Obj.is_block t;; - : bool =3D true # Obj.is_block (Obj.repr ());; - : bool =3D false # Obj.tag t;; - : int =3D 247 # Obj.closure_tag;; - : int =3D 247 So this is a closure, so a function that should have a functional type. I've tried to play with the devil, and here my result : # (Obj.magic( Printf.printf "%{%d%s%}" "kk%dkk%s\n") 5 "rae" () : unit );; %i%s- : unit =3D () Very strange indeed. Well, this should be reported in the bug tracking system.