Ö
Öö Tiib
On Nov 22, 8:55 am, Good Guy <[email protected]> wrote:
[...]
For idealist taste C++ has way too many flavors of parameter passing.
Ideally necessary and sufficient are two flavors: A) input-only
parameter and B) input-output parameter.
What about output parameters? This is what C++ really lacks.
I prefer to use return value as output-only. When there are multiple
outputs i prefer to wrap them into pairs or tuples (or classes when
the combination has useful meaning). When the output may be missing i
prefer to have a "nullable", "optional" or "fallible" return type (or
to throw on rarely actually expected error cases).
The cases when i have to use output-only parameters are usually in
some language-neutral or cross-language interfaces that have limits
about value types and their usage. On such cases however the interface
requirements define the limits (and what to do with output-only
parameters).