Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Parameter (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Drawbacks=== Output parameters are often discouraged in modern programming, essentially as being awkward, confusing, and too low-level β commonplace return values are considerably easier to understand and work with.<ref name=CA1021>[http://msdn.microsoft.com/en-us/library/ms182131.aspx CA1021: Avoid out parameters]</ref> Notably, output parameters involve functions with side effects (modifying the output parameter) and are semantically similar to references, which are more confusing than pure functions and values, and the distinction between output parameters and input/output parameters can be subtle. Further, since in common programming styles most parameters are simply input parameters, output parameters and input/output parameters are unusual and hence susceptible to misunderstanding. Output and input/output parameters prevent [[function composition (computer science)|function composition]], since the output is stored in variables, rather than in the value of an expression. Thus one must initially declare a variable, and then each step of a chain of functions must be a separate statement. For example, in C++ the following function composition: <syntaxhighlight lang="cpp"> Object obj = G(y, F(x)); </syntaxhighlight> when written with output and input/output parameters instead becomes (for <code>F</code> it is an output parameter, for <code>G</code> an input/output parameter): <syntaxhighlight lang="cpp"> Object obj; F(x, &obj); G(y, &obj); </syntaxhighlight> In the special case of a function with a single output or input/output parameter and no return value, function composition is possible if the output or input/output parameter (or in C/C++, its address) is also returned by the function, in which case the above becomes: <syntaxhighlight lang="cpp"> Object obj; G(y, F(x, &obj)); </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)