Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] printf and scanf
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pixel <pixel@m...>
Subject: Re: [Caml-list] printf and scanf
Jérôme Marant <jerome.marant@free.fr> writes:

> 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.

this only shows that " %2$s %1$d" is not a valid translation of " %s %d",
since they do not have the same type, and would fail at runtime (using this in
C would give you a segfault).

" %2$d %1$s" with type "string -> int" is a valid translation of " %s %d"

this means that not checking the translations could lead to a hole in the type
system, and so printf must be prepared to detect type errors (which it
currently does :)
-------------------
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