Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2001-12-20 14:16:16


On 12/20/01 11:04 AM, "rogeeff" <rogeeff_at_[hidden]> wrote:

> Why not like this:
>
> BOOST_START_FORMAT_DEFINITION( classic_date_format, 3 (int,int,int))
> arg1 << '-' << arg2 << '-' << arg3
> BOOST_END_FORMAT_DEFINITION
>
> BOOST_START_FORMAT_DEFINITION( us_date_format, 3 (int,int,int))
> arg2 << '/' << arg1 << '/' << arg1
> BOOST_END_FORMAT_DEFINITION
>
> BOOST_START_FORMAT_DEFINITION( long_date_format, 3 (int,int,int))
> day_of_week( arg1, arg2, arg3 )
> << ' ' << arg2 << '/' << arg1 << '/' << arg1
> BOOST_END_FORMAT_DEFINITION
>
> The third format you wont be able to implement using fixed prinf
> syntax.

But the translators aren't editing C++ code. You seem to miss the point of
my comments. These translators translate programs by changing only strings
in a string dictionary. They never look at the C++ code, and they don't have
any way to change the code.

If they were changing C++ code, then they could do all sorts of interesting
things, but that's really a separate issue.

>> 1) reordering capabilities for translators on projects that
> translate by
>> string
>
> I can provide not only reordering capabilities

For translators on projects that translate by string? No.

>> 2) more-terse way to specify format
>
> My way is not terse enough?

Not even close, no. I think that:

    BOOST_START_FORMAT_DEFINITION( classic_date_format, 3 (int,int,int))
    arg1 << '-' << arg2 << '-' << arg3
    BOOST_END_FORMAT_DEFINITION

Followed by later code that uses the format is definitely less terse than:

    cout << format("%1-%2-%3") << a << b << c;

It's hard to imagine anyone arguing otherwise!

>> 3) easier to decipher the format because it's "by example" --
> the format
>> looks something like the final result
>
> My way is not easy enough?

A matter of opinion I guess. Your proposed formats seem harder to understand
to me -- there's no template that looks like the final result without a lot
of formatting characters in there.

>> 4) translators on projects that translate by string can easily
> alter
>> format specifications like precision or padding
>
> So do I.

On projects that translate by string? No.

> And still don't.

OK. I haven't convinced you. And you haven't convinced me.

So you and I done discussing this for now, I guess.

    -- Darin


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