Browse thread
ocaml 2.02 bug: curried printf
[
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: | -- (:) |
| From: | John Prevost <prevost@m...> |
| Subject: | Re: another approach to sprintf (Re: ocaml 2.02 bug: curried printf) |
Christian Lindig <lindig@ips.cs.tu-bs.de> writes: > The suggested functional approach to printf has another possible > drawback: when you want to express all the options like "%5.5f" > possible in C style printf formatting you need a whole bunch of > functions. Since OCaml has no overloading a single `float' function > for floats can not capture them all. Yes, but you can still get the formatting features you want by having both formats that take arguments (like "lit") and also higher-order formats (for example, a format which truncates whatever format it is given to a specific string length, or a format that right justifies within a certain length, or etc.) In fact, the system is more powerful precisely because you can do things like this to extend the system. Not only can you do %5.5f, you could also make something to display the float in binary, or to display the fraction as a vulgar fraction symbol (i.e. ½). John.