What's really desireable is to never ever use output parameters.

Atila


On Thursday, 30 October 2014 at 09:39:42 UTC, Ola Fosheim Grøstad wrote:
On Thursday, 30 October 2014 at 08:02:49 UTC, Paulo Pinto wrote:
3. No non-const ref parameters to functions, use pointers. They want a visible "&" at call site for output parameters. e.g. "read(&var)" so that you don't have to look the function up in the docs.


Coming from a Quick/Turbo Basic/Turbo Pascal background, I never understood the C culture about function parameters.

Just another example of C being unsafe.

C is unsafe, but it is desirable to make it visible at the call site that you are returning a value through a parameter. I think it is a good idea to create a special "zero-cost" wrapper type so that you write:

copy_from_to( input, returns(output) )

I noticed that c++11 has a ref() function:

http://en.cppreference.com/w/cpp/utility/functional/ref

Reply via email to