Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2002-01-23 23:22:26

This is for the format library currently under review.

I haven't actually run the code due to my own compiler limitations, but I've
taken a look at the code and read the comments on the list. I agree with
Robert Stewart that an approach like:

> Try deviating from the printf-like notation in the format string since this
> isn't allowing for any printf-like functionality:
> format("[3], [1] [2]-th try")[40.23](hex)[50]["toto"];
> The [] pairs match in the format string as well as in the "parameters list,"
> you always have delimiters on either side of the positional parameter, so
> you don't need %n versus %{n}, and you get the syntactical difference
> between values and manipulators.
> This format offers a couple of valuable things. First, as someone pointed
> out in another post, putting parentheses around manipulators allows the eye
> to downgrade their importance in reading the expression. Second, we are
> accustomed to subscripting operations being chained like this, whereas we
> aren't accustomed to seeing chains of modulus operations. (I don't think of
> this as subscripting any more than I think of << and >> as bit shifting
> operations when working with streams. I just see the concatenation of
> multiple subscripts as ordinary, and thus more comfortable.)

The current approach seems confusing, both in us trying to understand it and
you trying to implement it. The printf syntax explicitly mentions the type
and formatting options for each parameter. C++'s better type checking
eliminates the need for the explicit typing, and the ability to add
manipulator objects eliminates the need for explicit formatting. You
shouldn't have two radically different ways to do the same thing, so the
printf interface should be dropped. With just positional parameters, the
library is easier to understand and create.

By the way, Robert's approach doesn't mention about how to write brackets.
Maybe we can have "%[" be a literal open square bracket, "%]" be a literal
close square bracket, and "%%" be a literal percent.

Another problem is the haphazard way the library is organized, especially as
you change it based on other requests. For now, we shouldn't accept this
library, so you can better organize it.

Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

Boost list run by bdawes at, gregod at, cpdaniel at, john at