当口头谈论方法时,我从不确定是否应该使用参数或参数或其他词。不管怎样,其他人都知道我的意思,但什么是正确的,这些术语的历史是什么?

我是一名c#程序员,但我也想知道人们是否在不同的语言中使用不同的术语。

声明一下,我是自学的,没有计算机科学的背景。(请不要让我去读《代码完成》,因为我这么做是为了让那些还没有史蒂夫·麦康奈尔这本了不起的书的人受益。)

总结

普遍的共识似乎是,在团队环境中可以互换使用这些术语。除非你在定义精确的术语;然后你也可以使用“正式参数/参数”和“实际参数/参数”来消除歧义。


当前回答

参数和参数

All the different terms that have to do with parameters and arguments can be confusing. However, if you keep a few simple points in mind, you will be able to easily handle these terms. The formal parameters for a function are listed in the function declaration and are used in the body of the function definition. A formal parameter (of any sort) is a kind of blank or placeholder that is filled in with something when the function is called. An argument is something that is used to fill in a formal parameter. When you write down a function call, the arguments are listed in parentheses after the function name. When the function call is executed, the arguments are plugged in for the formal parameters. The terms call-by-value and call-by-reference refer to the mechanism that is used in the plugging-in process. In the call-by-value method only the value of the argument is used. In this call-by-value mechanism, the formal parameter is a local variable that is initialized to the value of the corresponding argument. In the call-by-reference mechanism the argument is a variable and the entire variable is used. In the call- by-reference mechanism the argument variable is substituted for the formal parameter so that any change that is made to the formal parameter is actually made to the argument variable.

来源:绝对的c++, Walter Savitch

也就是说,

其他回答

在编辑工作中,我经常被人们忘记:结构语言是基于自然语言的。

用英语

“参数”是一个占位符。他们用口语设定回答格式。根据定义,它是呼叫的一方,限制响应。

“论点”是一个正在被考虑的立场。你争论你的观点:你考虑一个论点。

主要区别

论证的主位作用是代理。参数的主题角色是接受者。

的相互作用

把参数看成男性部分,把参数看成女性部分。实参进入形参。

使用

通常在定义中使用参数。实参通常用于调用。

问题

完成这个句子,使它不那么不和谐。

(A)说到定义:

将使用什么参数[]? 参数[]是什么[]?

(B)说到祈祷:

您将使用什么参数,[]? 这个参数[]将是什么[]?

答案

(A)

On /in/against/使用此参数 论点(s)……取

(B)

有什么例子吗 论点(s)……使用/ /反对/

重叠

你可以想象,在回答:在口语中,这些词有时会产生相同的反应!

所以,作为规则:

通常,如果有人想要参数信息,他们想要了解更多关于类型、变量名等的信息。如果你只给出例子论证,他们可能会感到困惑。 通常,如果有人想要参数信息,他们想知道你传递给函数或它的形参的值是什么。

在参数(计算机编程)-维基百科中有完美的解释

宽泛地说,形参是一种类型,实参是一个实例。

在函数定义f(x) = x*x中,变量x是一个参数;在函数调用f(2)中,值' ' 2是函数的实参。

和参数-维基百科

在计算机编程中,通常使用两种参数的概念,它们被称为参数和实参,或者更正式地称为形式参数和实际参数。

例如,在函数的定义中如

y = f(x) = x + 2,

X是定义函数的形式参数(参数)。

当函数对给定值求值时,例如

F(3):或者,y = F (3) = 3 + 2 = 5,

被定义的函数计算的实际形参(实参);它是一个给定的值(实际值),取代了定义函数的形式参数。(在日常使用中,术语parameter和argument可能会无意中互换,从而被错误地使用。)

函数/方法的参数向您描述它用于计算结果的值。

函数的实参是在函数/方法的特定调用期间赋给这些形参的值。

形参是函数声明中的变量。

参数是传递给函数的变量的实际值。

函数的形式形参在函数声明中列出,并在函数定义的主体中使用。形式形参(任何类型的)是一种空白或占位符,在调用函数时用一些东西填充。

实参是用来填充形式形参的。当你写下一个函数调用时,实参会在函数名后面的括号中列出。在执行函数调用时,将插入形式形参的实参。

The terms call-by-value and call-by-reference refer to the mechanism that is used in the plugging-in process. In the call-by-value method only the value of the argument is used. In this call-by-value mechanism, the formal parameter is a local variable that is initialized to the value of the corresponding argument. In the call-by-reference mechanism the argument is a variable and the entire variable is used. In the call- by-reference mechanism the argument variable is substituted for the formal parameter so that any change that is made to the formal parameter is actually made to the argument variable.