Talk:Parameter (computer programming)
This level-5 vital article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
|
Argument vs. Parameter
[edit]There are no sources for the article. Could someone please provide a source for the distinction between parameters and arguments? Otus (talk) 18:39, 11 June 2008 (UTC)
- I've been a PhD computer scientist for over 20 years, and I'm also an amateur stickler about English word usage. I have never seen the rigid distinction between "parameter" and "argument" that this article attempts to make. On the contrary, the terms "formal parameter" and "actual parameter" are well established terms in computer science and have been for decades, thus clearly suggesting that a "parameter" is not necessarily only a formal parameter. This article needs to be re-written to remove this misleading distinction between "parameter" and "argument". -- DBooth (talk) 17:17, 8 February 2012 (UTC)
- For example, see Formal and Actual Arguments -- DBooth (talk) 17:33, 8 February 2012 (UTC)
- I'm notably younger than DBooth, but I've worked with programming in several companies, and they made the same distinction. The course I teach also makes that distinction. I tell students that both "formal parameter / actual parameter" and "parameter / argument" are used, which has been my experience. I prefer "parameter / argument" because it's far simpler, and "actual parameter" is a bit silly sounding when you're referring to something that may be passed in by copy (in which the "actual parameter" is not what is accessed inside the method). But people do use that terminology, yes. TricksterWolf (talk) 01:28, 26 February 2012 (UTC)
I am also a Ph.D. (and an associate professor) in computer science (programming language theory, in particular - my thesis was about parametricity of some lambda-calculi) and have not heard of such a distinction (not that it is wrong, in particular since I am not a native English speaker). Please give a reliable source (or, better, multiple reliable sources) that "parameter" by itself means a formal parameter and "argument" by itself means an actual argument. (I am aware that some language standards such as ISO C and JLS say "formal parameter" and "actual argument".) Ejrsmi (talk) 21:40, 3 January 2013 (UTC)
The use of the term "unbound" here is confusing and misleading. It is used to mean "not bound to a value", which is a programming-language specific usage. Typically we say that a (formal) parameter is *bound* in the function definition, taking that terminology directly from mathematical logic. Cerberus (talk) 19:34, 18 January 2019 (UTC)
Section 2.1 on Eiffel needs improving. It says that arguments and parameters are different, defines arguments, then fails to define parameters. It says they can be formal or actual, and it gives one way that formal generic parameters can be used (which presumably does not apply to all formal parameters), but neither of these constitutes a definition. Adam1729 (talk) 22:53, 30 June 2024 (UTC)
Sources
[edit]Sources for any of this material? —Preceding unsigned comment added by 65.209.67.124 (talk) 01:58, 6 February 2008 (UTC)
Error
[edit]Parameter and argument are considered as same in this article. It's wrong and sloppy. Arguments are values binded to the parameters. For example in function definition define max(a,b) : if a < b then b else a;
has two parameters, a and b. When we make a function call max(1,2), the numbers 1 and 2 are function arguments. This is common use of these terms in computer sciense/engineering. Somehow wikipedia has mixed these two together. Please correct this.
- I made quite a lot of changes to address this. Should be clear now. --Alan 23:18, 18 January 2006 (UTC)
- Looks good, though there was a bit of confusion reintroduced regarding call-by-name/call-by-value (which are actually orthogonal to calling conventions -- an evaluation strategy for parameter passing is a property of the language, whereas a calling convention is a property of a particular compiler, platform, and/or build). --bmills 02:40, 19 January 2006 (UTC)
- I've been a PhD computer scientist for over 20 years, and I'm also an amateur stickler about English word usage. I have never seen the rigid distinction between "parameter" and "argument" that this article attempts to make. On the contrary, the terms "formal parameter" and "actual parameter" are well established terms in computer science and have been for decades, thus clearly suggesting that a "parameter" is not necessarily only a formal parameter. You may personally believe that this distinction should be made, but it does not reflect the long-established usage of these terms in the field of computer science. Please feel free to lobby for such usage on your own blog, but this article needs to be re-written to reflect the actual, long-established use of these terms, which does not' make such a distinction. -- DBooth (talk) 17:17, 8 February 2012 (UTC)
- For example, see Formal and Actual Arguments -- DBooth (talk) 17:33, 8 February 2012 (UTC)
call-by
[edit]What is the difference between call-by-result and call-by-copy-restore? They seem to be defined identically. Derrick Coetzee 20:53, 6 Oct 2004 (UTC)
call-by-result is call-by-copy-restore with an uninitialzed variable. There are some factual errors in the "calling conventions" section of this article, which will hopefully be corrected in the migration to evaluation strategy. --bmills 21:09, 23 October 2005 (UTC)
Cleanup
[edit]This article is not very encyclopedic. It would be great for a programming tutorial, but not for an encyclopedia. – flamurai (t) 02:52, Feb 12, 2005 (UTC)
- I'm working on a cleanup and rewrite this week. I'm going to move a cleaned-up version of the "calling conventions" (which are really evaluation strategies) into a forthcoming article I've stubbed (evaluation strategy); I think the rest of the article is pretty much redundant with subroutine (which is much larger and therefore likely to be better maintained), so I'm going to recommend that the rest of the article be dropped and redirected to subroutine. --bmills 07:10, 23 October 2005 (UTC)
I rewrote the article somewhat. I removed the {{mergeto}} notice based on the number of individual articles that could be considered sub-articles of this, or that could be merged into this. They include function argument (I just merged it to here), default argument, and named parameter. There are also four foreign-language pages for this specific article. I also moved the overloading section to subroutine, as, IMHO, it doesn't have anything to do with specific arguments per-se, as in strongly-typed languages, it's implemented by creating a second copy of the subroutine. --Interiot 21:29, 10 November 2005 (UTC)
- Looks like a positive change — the article as now phrased is surprisingly not redundant with subroutine, and the level of quality is much higher! --bmills 19:54, 12 November 2005 (UTC)
It might be worth pointing out that in some languages (C++ at least), in formal usage, there's a distinction between the meaning of 'argument' and 'parameter', as per [1]. --samdutton 08:30, 21 December 2005 (UTC)
- These are covered somewhat at Parameter#Computer_science in case anyone wants to incorporate some of that text here. I don't quite grok the distinction myself though. Is it just like the difference between a function prototype, and instances of calling a function? Or is there more to it than that?
- Also, regarding things like Macro#Macro_languages... it would be nice if someone who is an expert in functional languages could expand the article to include some of the formal concepts from functional programming. --Interiot 18:22, 21 December 2005 (UTC)
In Parameters and Out Parameters.
[edit]What do you mean by in parameter and out parameter? Does in parameter means call by value and out parameter means call by reference? This is respect to C programming language. (TC).
Bold text
Strike-through text
Note: the above comment was added 2006 October 18 by Rsb161702, in this edit; this is the user’s only contribution (as of this writing). The revision of the page at that time (this edit) did not mention “in parameter” or “out parameter”; I believe the original poster was asking for clarification on these. As of this edit and earlier ones, I have added a section on Output parameters (more abstractly, “parameter modes”), which explains these. The original poster also expressed the common confounding of these with call by value and call by reference; I have explained (with references) that these are not the same (as discussed in Ada ’83 Rationale), and may even be backwards (as in PL/SQL)!
To answer the original question: C has no built-in notion of in parameter and out parameter, but the same effect as output and input/output parameters is very commonly used in C by passing pointers to functions and modifying the value that they point at, and one calls these “input parameters” and “output parameters” based on how they are used, though there is no specific language support for them. C is call by value, but this value may be a pointer, which allows one to get the same effects as call by reference, though with different syntax. One can get the effect of an input/output variable by passing a pointer to C function and then reading or modifying the value that it points at. Many other languages do have built-in notions of input parameters and output parameters. Hope this helps future readers!
- —Nils von Barth (nbarth) (talk) 11:11, 5 October 2013 (UTC)
unclear wording
[edit]The article says "At runtime, the values assigned to these variables are passed to the subroutine sum. In the sum subroutine, the parameters addend1 and addend2 are evaluated, yielding the arguments 40 and 2, respectively. The values of the arguments are added, and the result is returned to the caller, where it is assigned to the variable sumValue."
Am I the only one who thinks this might make someone believe that the C programming language uses lazy evaluation? Could we somehow make clear that the values for parameters 'addend1 and 'addend2' aren't evaluated in the subroutine? That the values are in fact evaluated before the subroutine call, and the only 'evaluation' of the parameters that happens in the actual subroutine is trivial?
--Avl (talk) 11:31, 5 October 2008 (UTC)
PowerShell
[edit]What is with the obsession with PowerShell? It seems out of place, given that PowerShell originated none of these technologies. Superm401 - Talk 00:33, 28 November 2008 (UTC)
I agree, PowerShell is probably the worst language to explain these concepts. Blecchi--88.197.144.239 (talk) 17:27, 21 May 2009 (UTC)
Adding More synonyms
[edit]I came here looking for some clarity on the different names by which these concepts are reffered to. The following would be a good addition :
Value Parameter == ByValue == Formal Parameter
Reference Parameter == ByReference == Actual Parameter
These are already in the article, but for sake of clarity, a summary would be interesting.
Blecchi.
--88.197.144.239 (talk) 17:33, 21 May 2009 (UTC)
- I don't think your interpretation is correct! Whether a subroutine uses pass-by-copy or pass-by-reference, it has both parameters (formal parameters) and arguments (actual parameters).
- In the case of pass-by-reference, the parameter is an alias for the argument, and both must be variables.
- In the case of pass-by-copy, the parameter is a separate variable which holds a (shallow usually, but depends on language) copy of the argument's value. In this case the argument can be a literal or a variable, but the parameter is always a variable (a local variable that exists only for the duration of that subroutine). TricksterWolf (talk) 01:38, 26 February 2012 (UTC)
"Distinguished" Argument and Parameter?
[edit]The place I teach uses the term "distinguished" argument or parameter to refer to the object off of which an instance method is invoked. Is there another more common name for this?
A quick search of relevant pages turned up no common definition for the distinguished argument (the invoking object) or the distinguished parameter (e.g., "this" in Java). TricksterWolf (talk) 01:32, 26 February 2012 (UTC)
Distinction between "argument" vs. "parameter" does not reflect real-world usage
[edit]This article makes a big deal about the distinction between the terms argument vs. parameter, but I asked several career programmers and computer scientists, and none are used to making this distinction in practice, and in looking at a variety of programming and computer science books, the names argument and parameter are often used interchangeably (other sources just pick one or the other). I’m sure there are sources that make a careful distinction between "formal parameter" vs. "actual argument" or whatever, but in a quick search I can't find any sources which shorten these separate things to just "parameter" vs. "argument", which seems likely to lead to confusion since the two are routinely conflated and given one name or the other.
If there is no survey of reasonably definitive sources backing up the claims of this article, I would recommend rewriting the lead section to make it clear that these terms are widely used interchangeably, and where a distinction is made, the terminology is often source-specific.
The article is also long and rambling with quite a bit that seems off topic or out of scope. –jacobolus (t) 18:44, 23 October 2022 (UTC)