|
Boost : |
Subject: Re: [boost] [convert] Now with Boost.Parameter interface.
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-07-02 01:40:30
And in addition to the unexpected effects, it just doesn't read or look right.
from(str, 0)(more stuff);
really makes me think 'more stuff' happens AFTER the conversion. This
is one of the examples of why C programmers and many other
language-ites just shake their heads at us. We can't seem to stick to
writing code that even follows the rules of the language. (obviously
the code, using a proxy, does follow the rules, but it doesn't look
like it does).
If you really want the multiple function call syntax, could we at
least somehow put it first?
ie (just one possible way), and note that 'convert' has become 'converter':
converter<int>(locale_ = loc)(throw_ = true).from(str, 0);
And as a bonus, I can reuse the 'converter' on the next line if I
store it somewhere.
And you can still use the simple 'convert' (without the er) if no
extra params are needed:
convert<int>::from(str, 0)
And now it really does return an int.
Tony
On Wednesday, July 1, 2009, David Abrahams <dave_at_[hidden]> wrote:
>
> on Wed Jul 01 2009, "Vladimir Batov" <batov-AT-people.net.au <http://batov-AT-people.net.au>> wrote:
>
>> From: "David Abrahams" <dave_at_[hidden]>
>>> ... What's wrong with
>>>
>>> int i = convert<int>::from(str, 0, locale_ = new_locale, throw_ = true);
>>
>> I personally to not feel there is anything wrong per se with the above. The reason I
>> did not pursue it was that it introduces a limit on the number of the parameters and I
>> did not see it offering any major advantages to balance that shortcoming over the
>> supported
>>
>> int i = convert<int>::from(str, 0)(locale_ = new_locale)(throw_ = true);
>>
>> On the other hand the supported interface seems to scale considerably better and is no
>> longer to type:
>>
>> int i = convert<int>::from(str, 0)(locale_ = new_locale)(throw_ = true);
>> int i = convert<int>::from(str, 0, locale_ = new_locale, throw_ = true);
>
> But again, it has the downside that none of your calls above can return
> an actual int. That can have unexpected effects, e.g. in
>
> some_function_template( convert<int>::from(str, 0) )
>
> when the deduced template argument is actually your proxy type.
>
> --
> Dave Abrahams
> BoostPro Computing
> http://www.boostpro.com
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk