|
From: Dean M. B. <mik...@gm...> - 2007-06-11 16:30:09
|
Hi Christian,
On 6/11/07, Christian Henning <chh...@gm...> wrote:
>
> And there were no problems. Does that makes sense to you?
>
Two issues here:
1. The unit test is a specification on how the interface is meant to
be. Although your solution would work, the readability of additional
parentheses aren't very appealing to me. The unit test is an example
in itself of how the interface *should* look like and I'd like
to_upper_ (and other future transformations to be implemented) to not
have the extra parentheses.
msg << transform(to_upper_, source_) ;
Reads better IMO than
msg << transform(to_upper_(), source_()) ;
The same way
boost::bind(&function, _1) ;
Reads better than
boost::bind(&function, _1()) ;
2. The premium is put on readability and extensibility. The transform
template function is meant to extend to more than just a pair of
parameters. For flexibility's sake, see the example below:
msg << transform(to_upper_, source_ & destination_)
<< transform(headers_, to_upper_ & trim_)
;
With template metaprogramming, operator& can be overloaded to produce
a composite selector and composite transformations. This gives
'transform' a flexible enough interface which allows:
msg << transform(to_upper_, source_) << transform(source_, to_upper_) ;
Of course, with the help of template metaprogramming. In this regard,
having extra parentheses doesn't help with readability.
NOTE: This is the direction of the transformation interface (and other
interfaces to the message type in general), to leverage on
compile-time meta-programming to produce readable and flexible
interfaces.
The above are the two rationale's for why I opted for 'extern
to_upper_placeholder to_upper_' instead of making it a typedef in the
first place. It just so happened that my first iteration
implementation hit a snag (which I sure hope would be temporary).
So the real question now would be (assuming it works with GCC) how we
can allow the above parentheses-less while keeping MSVC and other
compilers happy?
--
Dean Michael C. Berris
http://cplusplus-soup.blogspot.com/
mikhailberis AT gmail DOT com
+63 928 7291459
|