What's the correct term for returning something as an out parameter?

224 views Asked by At

I hope this question is on topic.

I was doing code review and stumbled upon the following function:

bool SomeFunc(std::string& o_xxx, char& o_yyy);

This function is used to retrieve the values of xxx and yyy of some class by means of out parameters.

The comments (which are later used for auto-documentation) say:

... this function returns by reference the [xxx] and [yyy]...

Obviously the function returns a boolean value indicating success or failure. So the sentence above need to be rephrased. But how? What's the correct term (if any) for returning something, as it were, by means of an out parameter, or, in other words, populating an argument passed by reference?

The question is tagged language agnostic, because it's not C++ specific. But it's also tagged C++ because the example is in C++.

4

There are 4 answers

1
Fred Foo On BEST ANSWER

"Upon success, SomeFunc stores in o_xxx and o_yyy the values ..."; stores in is how the Linux manpage strtoul(3) describes what that function does with its endptr argument.

Though I've also heard the phrase "return in" often enough with reference-typed out parameters.

1
iammilind On

In simplest words:

Function SomeFunc() can modify parameters xxx(std::string) and yyy(char) and returns success or failure (bool).

0
GSerg On

Consider the MSDN way. Example.

Return value is described in its own section.
Manipulations with output parameters are described in their own sections and may be optionally repeated in the Return Value section.

0
BЈовић On

If you are using doxygen, then this would do :

/**
 *- Description : This function ...
 *
 * @param[out] xxx ...
 * @param[out] yyy ...
 *
 * @return true for ..., false otherwise
 *
 ***********************************************************************/