Boost logo

Boost :

Subject: Re: [boost] [log] Comments
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-03-16 16:02:19


Hi,
I've tried to follow this discussion, without reading the Boost.Log documentation.

----- Original Message -----
From: "Andrey Semashev" <andrey.semashev_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, March 16, 2010 8:19 PM
Subject: Re: [boost] [log] Comments

>
> On 03/16/2010 09:44 PM, Steven Watanabe wrote:
>> AMDG
>>
>>>> This specialization is bad if it forces you to have separate attrs.
>>>
>>> From their implementation standpoint, they have nearly nothing in common.
>>
>> Then all the sophisticated implementation doesn't belong in attr.
>> It belongs in the whole formatter/filter object.
>>
>>> You mean, like this:
>>>
>>> bind(begins_with, bind(attr< std::string >("Tag"), _1)), "Important")
>>>
>>> ?
>>>
>>> Compared to my syntax, this looks cryptic, to say the least.
>>
>> No I meant, begins_with(attr<std::string>("Tag"), "Important").

I like this. It is clear the result of begins_with is a filter on std::string, which is independent of the specific attribute itself.

>> I don't understand why you think that random extra stuff
>> is needed just because a member function is turned into
>> a non-member. FWIW, the bind syntax would mostly work as is with
>> no extra work from you, if attr just returned a function object,
>> so I don't think it's necessarily a bad thing, since I really do not
>> like to see you reinventing the wheel in so many places.
>
> I understand where you're leading - to rewrite filters and formatters in
> terms of Proto or Phoenix. I admit that you made a few very good points,
> and I'm not against this move. But I'm not ready to drop my syntax
> advantages in the process. Ideally, I would prefer that the current
> syntax was possible without changes in the rewritten code. In order to
> complete this task I'll need time to study these libraries closer.

I don't see why do you need Phoenix to implement this function, However Proto will help you surely.

>From my point of view

attr< std::string >("Tag").begins_with("Important")

is more intrusive than

begins_with(attr<std::string>("Tag"), "Important").

And the last is as clear as the first.

In addition, as the attributed are typed,

The following has no sense to me

attr< int>("Att").begins_with("1")

Does this works now? What it does?
 
>>>> Have you measured the effect? Oh, I see what you mean. I
>>>> would have no problem if you dropped the format parameter
>>>> of attr entirely.
>>>
>>> But I don't want to drop it. It's quite useful.
>>
>> You can already use Boost.Format at the top level.
>
> This feature is useful in streaming formatters.

I think attributes must be a different entity from filters and formatters. A filter or a formatter can concerns several attributes.

The following is an attributte or a formatted attribute.
attr< int >("X", "%04x")
Which is its value type int or std::string?

The following is clearly the format of an attribute. There is no ambiguity.
format("%04x",attr< int >("X"))

Best,
Vicente


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