|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-06-29 14:31:54
----- Original Message -----
From: "Beman Dawes" <bdawes_at_[hidden]>
> I missed the original discussions some months back, but just looking at
> your example above,
>
> * Very Interesting work!
>
> * The choice of arithmetic operators "*" and "%" is totally unsettling to
> my eye. Let's try it with "<<":
>
> cout << format("[%=6s] [%+6s] [%+6s] [% 6s] [%+6s] [%s]\n") << 123
> << internal << setfill('W') << 234
> << internal << setfill('X') << -345
> << setfill('Y') << 456
> << setfill('Z') << -10
> << "foo"
> << "bar.\n";
>
> That seems ever so much better if you can pull it off.
I am quite taken with Sam's use of '%'.
1. Python uses % for this purpose, with roughly identical operator
precedence and it works well
2. We really aren't doing streaming in this case. It might be better to use
a distinct operator to separate formatting from streaming.
3. Less typing - one of the original motivations of the format challenge was
that doing output formatting in C++ costs many more messy characters than it
used to in C.
4. As Sam pointed out in private email, % has some nice precedence
properties.
The use of * is a little strange to me, but for non-sticky users it would
probably not show up, right?
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk