|
Boost : |
From: Alisdair Meredith (alisdair.meredith_at_[hidden])
Date: 2003-04-23 21:01:09
> "Justin M. Lewis" wrote:
> My idea was, if you make a simple template class, originally I called
> it CRetVal, you could force people to specify at the time the function
> is called what's going on. I made a helper template function retval
> that would create and return a CRetVal object of the desired type to
> save from needing to use template notation in line all over the
> place. So, the above would become something more like.
> void func(CRetVal<int> x){x = 1977;};
Interesting idea. I think I like it, similar to the way I like the idea
of an unmanaged_ptr<> template to indicate deliberate raw pointer use
clearly.
Unfortunately, I think it is a hard sell, persuading people to type many
more characters to do something they have been familiar with using much
leaner syntax for years. If clarity matters it is usually indicated by
clear function/parameter naming, handily placed comments etc. so various
strategies for coping with the problem are out there.
Persuading people that the increased clarity of intent for the single
parameter is worth the extra code-obfuscation of the call as a whole (as
any additional wrapper-syntax tends to obfuscate) may be a hard sell.
On the basis that nothing teaches like experience I'd certainly be
interested in giving it a go here though <g>
-- AlisdairM
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk