Boost logo

Boost :

Subject: Re: [boost] Conversion review
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-08-23 12:56:30


Le 23/08/11 11:20, Ralph Tandetzky a écrit :
> A note to an earlier message before I start my review:
>>> - STL conversions
>>>
>>> I believe these functions are of little use as when I would have to
>>> convert a list of integers to a list of doubles I'd simply write a
>>> loop (possibly aided by BOOST_FOREACH) instead of looking up a library
>>> (and reading the necessary documentation) to do it for me.
>> I respect your approach, but I have see tones of code using these
>> kind of loops that cluter the comprehension of the code. I prefer to
>> use a function. Nothing forces you to use this function.
>>> With the offered customization points the cure seems to be worse than
>>> the disease, if I had to convert a std::pair<int, int> to a
>>> std::pair<double, double> I'd write a quick function to do so.
> There's nothing easier than converting a list of integers to a vector
> of doubles:
> std::list<int> li;
> // fill list with something ...
> std::vector<double> vd( li.begin(), li.end() );
> Concerning std::pair<int,int> to std::pair<double,double> conversion:
> There's already a template constructor in the std::pair class which
> does that.
>
> My review:
>
>
> * What is your evaluation of the documentation?
> Looks quite accurate. For my taste the documentation is a litte to
> verbose. For example the bullet points in "How to Use This
> Documentation" can be left out in my opinion. There were a few typos:
> "Unfortunately this doesn't work<s> as overload resolution doesn't
> take care of template type parameters that can not be deduced from the
> function arguments. *Boost.Conversion* provides a customization
> <customization> point that takes in account the |Source| and the
> |Target| types (see below). "
>
OK. I will correct it.
> * What is your evaluation of the potential usefulness of the library?
> I don't like implicit conversions in the first place. This hasn't
> anything to do with the library itself. But providing implicit
> conversions can create temporary objects or make a program behave
> weird in the strangest places. Sometimes versions of overloaded
> functions are called, you wouldn't expect. Some stuff compiles, where
> you would rather have a compile time error than a runtime crash. I try
> to avoid implicit conversions and prefer handwritten conversion where
> neccessary. This way you will always know what's happening in your
> code. Therefore the library would not be of great use for me. I'm not
> against implicit conversions per se, but from my experience they
> should be used with great care. Using this library might suggest the
> opposite to the unexperienced user.
The library provides implicit and explicit conversions, and as you have
surely remarqued you need to use an explicit function to get them
(implicitly), so the conversion is not realy implicit. No risk for the
unexperienced user as it need to state explicitly that he want implicit
conversion ;-)
>
>
> * Do you think the library should be accepted as a Boost library? Be
> sure to say this explicitly so that your other comments don't obscure
> your overall opinion.
> NO. Explicit conversions might be fine, but implicit conversions
> should be used with great care and should mostly be avoided. I
> mentioned reasons for that in the answer about usefullness. Explicit
> conversion can be done by handwritten functions without studying
> another library.
>
> I can understand that you could prefer handwritten functions to make
> explicit conversions. The library helps you to make these handwriten
> functions to the point you will not need them (the hadwritten)
> anymore, just include a specific file.
Thanks for your review,
Vicente


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