Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-12-20 10:57:26


At 03:48 AM 12/20/2001, Samuel Krempp wrote:

>On Thu, 2001-12-20 at 02:52, Karl Nelson wrote:
>
>> If you want to force rules of presidence use what is given for
>> that...
>>
>> cout << (format(str) << 1 << 2) << endl;
>>
>> The class could be designed to handle that.
>
>It could, but then in those cases it would act like a string-maker, not
>a manipulator.
>(inside the parenthesis, format doesn't know about cout's state. So it
>does its formatting, and then dump a string at the end. There is no way
>to stack the arguments and wait until you get cout, before formatting
>them)
>So format would have a different behaviour there, and it would not be
>apparent.
>So all in all, I guess you would not make the class handle that, unless
>it always act like a string-maker like mine.
>
>In fact, I realised you use operator<< because you aim at making format
>pretty much like a manipulator.
>while my class is a string maker , for which operator<<(stream, format)
>is define to facilitate the use inside stream output chains.
>
>that's the heart of the issue..
>In my experiments, it seemed to me it wasn't possible to make the format
>objects act like a manipulators in all aspects, I'd always get a dirty
>aspect sooner or later. I'll try to recall the details for this evening,
>to debate whether we should stick to a simple string-maker or aim for a
>'stream manipulator' approach. This choice governs the choice between
><< and %.

Because the "manipulator-like" approach looks so familiar, and the
"string-maker" approach looks strange at first, that in of itself is an
argument for the manipulator-like approach.

Of course if it turns out there are other killer arguments in favor of the
string-maker approach, you should choose string-maker.

But if it is even close to a toss-up, consider that the manipulator
approach many be easier to teach, easier to learn, and be viewed as the
more mainstream approach. I worry that we will all waste endless time
explaining why string-maker was chosen over manipulator.

Whichever you choose, please carefully document the rationale!

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk