Boost logo

Boost :

Subject: Re: [boost] Review Request: Introduction of boost::stringnamespace and string-conversion functions
From: Vladimir Batov (batov_at_[hidden])
Date: 2009-02-18 00:43:33


Robert,

Apologies for snipping the rest of your post. The thing is I agree with all
you say, the reason I am replying to the snippet below is to try to explain
myself.

Best,
V.

>> > Consider what can be extremely common:
>> >
>> > void f()
>> > {
>> > using boost::<something>::from;
>> > ...
>> > std::string s(from(i));
>> > ...
>> > s = from(j);
>> > // etc.
>> > }
>> >
>> > "from" is not as meaningful. That name almost requires
>> retaining the
>> > enclosing namespace or a namespace alias.
>>
>> ... It is clearly a bad practice. The solution is *not* to deploy it.
>
> Wow! I thought we were being reasonable until this point.
> Apparently, I'm a horrible developer and clearly do bad things.
> In case my sarcasm isn't obvious, I do not accept your criticism
> of what I showed in the example. It *is not* bad practice.

Well, I obviously was not very successful arguing my point, was I? :-)
Somehow cramming a view into a sentence or two brings the results exactly
opposite to anticipated. My humble apologies (I never meant to imply
anything "horrible") and please let me try again.

I feel that our good vs. bad are relative. Namely, within the scope of your
example it is clearly good. I interpret the example above as the programmer
saying -- why formalities amongst friends, call me Rob. And that clearly
works wonderfully as in your example with "Dad" as it does not lead to
ambiguities. In that context I personally do not feel that in your example
"from" is any less meaningful -- I have the "using" directive right in front
of me and even without it I cannot resist but read "std::string s(from(i));"
just as it is written -- "string s from i". I can't really think of anything
else apart from what it *actually* does.

Having said that, as calling "Dad" in a crowd is likely to turn a few heads,
deploying

    using something-long something-short;
    typedef something-long something-short;

within a bigger scope it is likely to lead to ambiguities and confusion. The
bigger the scope the less meaningful is "from", i.e. doing so should (IMHO)
be avoided. And that IMHO is not limited to this particular "from". *That*
is what I referred as bad practice (I am guilty of interpreting your example
too liberally).

Again, please accept my humblest apologies for my clumsy attempt to explain
my position. I am hoping I managed it better this time.

V.


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