按值调用和按值传递是同义词吗?
我一直认为按值调用和按值传递是同义词。然而,我最近听到有人称它们为不同的东西。它们是同一件事吗?
我也在谈论它们相应的引用术语。
I always thought call-by-value and pass-by-value were synonymous. However, I recently heard someone refer to them as if they were different. Are they the same thing?
I'm also talking about their corresponding by-reference terms too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
“某人”是错误的。查看维基百科文章,它直接回答了您的问题。您也可以在本文中指出某些“某人”:
"Someone," is wrong. Check out the Wikipedia article which directly answers your question. You can point that certain "someone" at this article, as well:
它们是同义的。
“调用”表示方法,“传递”表示参数。
示例:
They are synomynous.
"call" means the method, and "pass" means an(the) argument(s).
Example:
是的,根据我的理解,这些术语是同义词。
但是,我认为您问错了观众。如果你的同事认为他们不同,那么你和他们的理解就不匹配。我是否认为它们相同并不重要,重要的是你的同事实际上意味着什么。
Yes those terms are synonyms as I understand them.
However, I think you are asking the wrong audience. If your colleague regards them as different, then you and they have a mismatch of understanding. Whether or not I think they are the same is irrelevant, what counts is what your colleague actually means.
它们是同义的。术语“按值调用” 与“按值传递” 含义完全相同。
不过,我更喜欢按值传递形式,因为它是传递它所引用的参数。调用可以具有按值传递的参数以及按引用传递的参数。
示例:
第一个参数是按值传递的引用,第二个是按值传递的值,第三个是按引用传递的引用,第四个是按引用传递的值。
They are synonymous. The term call-by-value means exactly the same as pass-by-value.
However, I prefer the pass-by-value form, as it's the parameter that is passed that it refers to. A call can have parameters that are passed by value as well as parameters passed by reference.
Example:
The first parameter is a reference passed by value, the second is a value passed by value, the third is a reference passed by reference, and the fourth is a value passed by reference.
我一直认为它们是同义词,但当我想到这一点时,也许他们试图区分直接调用方法和通过引用(即委托)调用方法。也就是说,考虑到:
他们是否试图说,如果你写:
那么它是“按值调用”,但如果你写:
那么它是“按引用调用?”
I've always considered them synonymous, but when I think about it, perhaps they're trying to differentiate between calling a method directly and calling a method through a reference (i.e. a delegate). That is, given this:
Are they trying to say that if you write:
Then it's a "call by value", but if you write:
then it's a "call by reference?"