Öö Tiib <> writes:
> Some other style guides suggest to minimize amount of raw pointers and
> avoid usage of unary &. I like such rules better.
Yeah, me too.
There's obviously a tradeoff, and neither way is "perfect"; it would be
cool if c++ had a way to indicate "out/modified" parameters, just to
make source-code more readable while preserving the goodness of
references over pointers.
Of course simply by use of references to const vs. non-const objects,
one can indicate this in the function interface to some degree, but I
gather what proponents of using pointers for out-arguments want is a way
of making it obvious at the _call-site_ that an argument is an output.
E.g.
...
SomeType output;
...
some_func (inp1, inp2 + 3, out: output);
substitute your prefered notation for "out:", e.g., "=>" might also be
fairly readable:
some_func (inp1, inp2 + 3, => output);
Since const-vs-non-const largely covers the actual type-checking, I
guess this would be largely cosmetic... I suppose to make sure people
actually remembered to use such notation, declarations could also have
these annotations, and enforce the rule that "if the declaration marks a
parameter as "out:" (or "=>"), then calls must also do so."
-Miles
--
You can hack anything you want, with TECO and DDT.
|