|
Boost : |
Subject: Re: [boost] Assign V2 - first impression
From: er (er.ci.2020_at_[hidden])
Date: 2011-06-23 13:06:55
>> While you only state a preference over V2, it's hard to see that you are
>> unhappy with it.
>>
> I think your library needs to do better than coming up with a slightly
> different syntax than V1, otherwise I don't see the point of having it.
Indeed, but I claim more than a slightly different syntax. The
fixed-arity stuff is quite a different syntax. The other stated goals of
the design, in the change-log, are, amongst other things, to bring these
improvements:
1- Code reuse because deque and put share the same crtp
2- Code decoupling (modularity)
3- Open for extension (albeit not enough, see my response to)
Do I have to argue that these objectives worthwhile?! No, so I please
ask whether they are were met, and if not, what is lacking. PS: maybe I
did not state 3-.
Let's assume I get paid for writing a TPS report, every day, involving
100 unit-tests such as the one below.
STL approach:
std::deque<int> cont;
const int n = 2;
int x = log10( 1 );
for(int i = 0; i < n; i++)
{
cont.push_front( x );
}
x = log10( 10 );
for(int i = 0; i < n; i++)
{
cont.push_front( x );
}
x = log10( 100 );
for(int i = 0; i < n; i++)
{
cont.push_front( x );
}
x = log10( 1000 );
for(int i = 0; i < n; i++)
{
cont.push_front( x );
}
assert(
boost::range::equal(
cont,
csv_deque( 3, 3, 2, 2, 1, 1, 0, 0 )
)
);
PS: No need to argue that a nested loop would made the job easier. Your
boss can make it as arcane as he likes and he might have as well
re-arranged 1, 10, 100, 1000 in a different order.
Assign 2.0:
BOOST_AUTO( _r, ( _repeat = 2 ) );
typedef function<int(int)> f_;
BOOST_AUTO( _d, ( _data = f_( log10 ) ) );
assert(
boost::range::equal(
csv(
deque<int, push_front_>( _nil) % _d % _r,
1, 10, 100, 1000
),
csv_deque( 3, 3, 2, 2, 1, 1, 0, 0 )
)
);
Does Assign (1.0-2.0) begins to add positively to your well being?
Assume, further, that you have to do the same thing all over again, but
you have to drop the function altogether, and replace push_front by
push_back. Is it better to write a function or use Assign?
As for 2.0, specifically, do we agree about *decoupling* of features
(_r,_d and push_front_)?
The same code above requires very minor modification if used with put()
rather than deque(), are we on the same page about *code reuse*?
Finally, let's say you want something other than repeat, that does not
already exits. You can write write a small class, that conforms to a
concept (ConceptModifier), and invoke two mere macros, and the job is
done. Do you agree about *open for extension*?
https://svn.boost.org/svn/boost/sandbox/assign_v2/boost/assign/v2/option/modifier/repeat.hpp
Please have a bit mercy and give me your updated impressions based on
these clarifications.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk