[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2002-05-02 (15:56) |
From: | Jérôme_Marant <jerome.marant@f...> |
Subject: | Re: [Caml-list] printf and scanf |
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. > > 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" string -> int de: " %2$s %1$d" int -> string This example shows that if you want a full featured internationalisation, you cannot state that "you know the type you expect" since you will only determine it at run-time. Cheers, -- Jérôme 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