Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Printf: variable field width/precision
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-08 (16:09)
From: Thorsten Ohl <ohl@h...>
Subject: [Caml-list] Printf: variable field width/precision
In the C library, printf(3) supports variable field widths and
precisions with the `*' specifier.

   The field width

       An optional decimal digit string (with nonzero first digit)
       specifying a minimum field width.  [...]  Instead of a decimal
       digit string one may write `*' or `*m$' (for some decimal
       integer m) to specify that the field width is given in the next
       argument, or in the m-th argument, respectively, which must be
       of type int. [...]

Unfortunately, neither the O'Caml library nor the compiler accept `*'.
If the `*' form is available, the `*m$' form is hardly needed, but I
couldn't find a way to hack around the missing `*' (handling every
conceivable width/precision pair as a special case doesn't count ...).

Is there are chance that variable field widths for the benefit of
numerical programs will be supported in the future?  [It would be easy
to hack the library, but since the compiler must perform its own magic
for type safety, I couldn't distribute the code without asking users
to patch the compiler.]

Or does anybody know a nice workaround?

Thorsten Ohl, Physics Department, TU Darmstadt -- [<=== PGP public key here]
Bug reports:  FAQ:
To unsubscribe, mail  Archives: