From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA12800; Sat, 27 Sep 2003 10:20:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA23402 for ; Sat, 27 Sep 2003 10:20:08 +0200 (MET DST) Received: from bourg.inria.fr (bourg.inria.fr [128.93.11.100]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8R8K7H18660 for ; Sat, 27 Sep 2003 10:20:07 +0200 (MET DST) Received: from starynke by bourg.inria.fr with local (Exim 4.22) id 1A3AJD-00046B-Ec; Sat, 27 Sep 2003 10:20:07 +0200 Date: Sat, 27 Sep 2003 10:20:07 +0200 To: Richard Jones Cc: caml-list@inria.fr Subject: Re: [Caml-list] Printf question Message-ID: <20030927082007.GA15720@bourg.inria.fr> References: <20030926180248.GA14053@redhat.com> <16244.54690.54537.392805@karryall.dnsalias.org> <20030927072325.GA14604@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030927072325.GA14604@redhat.com> User-Agent: Mutt/1.5.4i From: Basile Starynkevitch X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 printf:01 basile:01 basile:01 andrieu:01 val:01 printf:01 sprintf:01 val:01 cristal:01 cristal:01 int:01 int:01 0200,:01 sep:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, Sep 27, 2003 at 08:23:25AM +0100, Richard Jones wrote: > On Sat, Sep 27, 2003 at 02:11:14AM +0200, Olivier Andrieu wrote: > > You could use the %a format. [...] > > I guess the problem with this is that I lose any type safety, > which is the whole point of doing things this way. > I don't think that %a in formats lose type safety (provided that the passed function has the correct type). # let pr= function 0->"zero" | 1->"one" | n -> string_of_int n;; val pr : int -> string = # let myprint n = Printf.sprintf "n=%a" (fun () n->pr n) n;; val myprint : int -> string = # myprint 1;; - : string = "n=one" -- Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr Project cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359 http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners