Boost logo

Boost :

From: Justin M. Lewis (boost_at_[hidden])
Date: 2003-04-23 23:19:26


I agree. I probably wouldn't have cared for this myself, had I never seen
the code I'm working on now. I mean, normally I work pretty independently.
But, now I'm stuck with the job of maintaining code that's been around
forever, has been ported several times to a couple different projects. In
places you can see how the code evolved over time. But, the point is, it's
becoming a mess. And, we're at a point where we're almost starting
everything again, but this time from scratch. Knowing that the code will
probably live for years, and be ported several times, and be maintained by
many different people over its life, it seems best to me to start a project
like that off with clarity being the #1 priority. And, at least in my
experience, people seem to think that functions that pass by reference
changing the values of params is a problem, it's hard to track. But, most
C++ people I know prefer to avoid pointer use. So, that really only leaves
the one option that makes the intent explicit and clear, every time.

So, I really can't give a long term analysis of how well this method works,
if it becomes a hassle to maintain it, or not. But, as it is, it seems more
clear to me than anything else. At the cost of 3 or 6 letters at the
invocation point, you can make the operation of the function clear.

func(out(x));

It seems pretty simple and straight forward to me.

Justin

----- Original Message -----
From: "Alisdair Meredith" <alisdair.meredith_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, April 23, 2003 7:01 PM
Subject: [boost] Re: class proposal

> > "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
>
> _______________________________________________
> 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