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 RAA11920; Thu, 2 May 2002 17:56:52 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA11656 for caml-list@pauillac.inria.fr; Thu, 2 May 2002 17:56:51 +0200 (MET DST) 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 KAA30413 for ; Thu, 2 May 2002 10:26:10 +0200 (MET DST) Received: from gwsmtp.thomson-csf.com (gwsmtp.thomson-csf.com [195.101.39.226]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g428Q9D09473 for ; Thu, 2 May 2002 10:26:10 +0200 (MET DST) Received: from thomplex.thomson-csf.com (200.3.2.2) by gwsmtp.thomson-csf.com (NPlex 5.1.053) id 3CCEA8790001B1DE for caml-list@inria.fr; Thu, 2 May 2002 10:29:01 +0200 Received: from thomplex.thomson-csf.com (200.3.2.2) by thomplex.thomson-csf.com (NPlex 5.1.036) id 3CCCD95D00061982 for caml-list@inria.fr; Thu, 2 May 2002 10:28:07 +0200 Received: from bgxplex3.bgx.airsys.thomson-csf.com (1.38.9.153) by bgxplex.bgx.airsys.thomson-csf.com (NPlex 5.1.053) id 3CAC2CE10004E6B9 for caml-list@inria.fr; Thu, 2 May 2002 10:25:35 +0200 Received: from bgxplex3.bgx.airsys.thomson-csf.com (1.38.9.153) by bgxplex3.bgx.airsys.thomson-csf.com (NPlex 5.1.053) id 3CC58155000111B9 for caml-list@inria.fr; Thu, 2 May 2002 10:25:25 +0200 Received: from 187.150.3.12 by bgxplex3.bgx.airsys.thomson-csf.com (InterScan E-Mail VirusWall NT); Thu, 02 May 2002 10:25:23 +0200 Received: from af_mara by lully.bgx.airsys.thomson-csf.com with local (Exim 3.22 #1 (Red Hat Linux)) id 173BuX-0000U8-00 for ; Thu, 02 May 2002 10:25:57 +0200 Date: Thu, 2 May 2002 10:25:57 +0200 From: =?iso-8859-1?Q?J=E9r=F4me_Marant?= To: caml-list@inria.fr Subject: Re: [Caml-list] printf and scanf Message-ID: <20020502102557.A1696@fr.thalesgroup.com> Mail-Followup-To: caml-list@inria.fr References: <20020501180052.GA13445@hell.mine.nu> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020501180052.GA13445@hell.mine.nu>; from fare@tunes.org on Wed, May 01, 2002 at 08:00:53PM +0200 Content-Transfer-Encoding: Quoted-Printable Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, May 01, 2002 at 08:00:53PM +0200, Francois-Rene Rideau wrote: > Jerome Marant wrote: > There are some cases where you may know the format string > only at runtime; the most obvious example is internationalization > through something like gettext. >=20 > Rather, the format strings are known at compile-time, > but you don't know which string will be used. > So you can precompile all strings, and > select the right formatter at run-time. I'm sorry, what do call "formatter"? Is it the format string or the formating function? > Even if you want to do things at runtime, you can compile the default > string at compile-time, and then you know the type to expect. This is true with the current implementation of printf in the Printf module. But this would be wrong if you consider parameter reordering in the C printf (the printf manual page gives enough good explainations= ). I've been giving the following example for quite long now: languages do not always order words the same way. So, sometimes, you need to reorder parameters in translated strings in order to get a correct syntax in the targeted language. With printf, you can do it this way: fr: " %s %d" =20 string -> int de: " %2$s %1$d" int -> string This example shows that if you want a full featured internationalisatio= n, you cannot state that "you know the type you expect" since you will onl= y determine it at run-time. Cheers, --=20 J=E9r=F4me Marant ------------------- 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